📜  Laravel - 查询生成器原始查询 selectRaw - PHP 代码示例

📅  最后修改于: 2022-03-11 14:54:53.654000             🧑  作者: Mango

代码示例1
$totalUsers = MyInventoryModel::selectRaw('pos_inventory.id as pos_inventory_id,pos_products.*,pos_products.product_name as product_name,pos_inventory.reorder_point,pos_inventory.reorder_qty,pos_inventory.current_stock,
                       pos_inventory.variant_id,pos_products.product_sku,pos_product_variants.combination_names,pos_product_variants.sku,pos_outlets.*,pos_roles.*')
                ->leftJoin('pos_products', 'pos_inventory.product_id', '=', 'pos_products.id')
                ->leftJoin('pos_product_variants', 'pos_inventory.product_id', '=', 'pos_product_variants.id')
                ->leftjoin('pos_outlets', 'pos_inventory.outlet_id', '=', 'pos_outlets.id')
                ->leftjoin('pos_roles', 'pos_outlets.store_id', '=', 'pos_roles.store_id')
                ->where('outlet_id', $item->outlet_id)
                ->groupBy('pos_inventory.product_id')
                ->get();