0
我有三個模型加入。僅當inventory.status
爲1(即有效)時,我需要獲得workspace_members
表格詳細信息。 我怎樣才能用尖銳的口才寫出這個條件?以下是我的查詢。提前致謝。Laravel基於條件的sql查詢
$data['inventories'] = Inventory::
Join('category_info','inventory.category_id','=','category_info.category_id')
->leftJoin('workspace_member_inventory', 'inventory.inventory_id', '=', 'workspace_member_inventory.inventory_id')
->leftJoin('workspace_members','workspace_member_inventory.member_id','=','workspace_members.member_id')
->where('inventory.workspace_id', '=', $workspace_id)
->select('inventory.*', 'workspace_member_inventory.member_id','workspace_members.*','category_info.category_name', 'inventory.status as status')
->get()
->toArray();