$productByEmployee = Product::leftJoin('custom_prices','custom_prices.product_id','=','products.id'
->leftJoin('categories','categories.id','=','custom_prices.category_id')
->leftJoin('custom_price_employees','custom_price_employees.category_id','=','categories.id')
->leftJoin('employees','employees.id','=','custom_price_employees.employee_id')
->select('products.name as product_name','products.price as noble_price','custom_prices.price as custom_price','category.name as category','employees.name as employee'
->where('products.id','=',2)
->get();
1条答案
按热度按时间bxgwgixi1#
为员工获取特定产品的自定义价格。
同一个查询可以根据不同的需要重用或修改。