'价格'是一个具有称为list_price的属性的对象。
$products =
Product::with(['child','price','variant','thumbnail','image',
'description'])->
take($recperpage)->get();
我打算按LIST_PRICE属性订购。我无法指定查询如下:
->orderBy('price.list_price','desc')
它不起作用。有帮助吗?我正在使用Laravel 5.3。
如果要订购查询,则必须在prices
表上添加一个加入。
更容易的解决方案是订购查询结果:
$products = Product::with(['child','price','variant','thumbnail','image', 'description'])
->take($recperpage)->get()->sortByDesc('price.list_price');