Bil*_*had 3 laravel eloquent laravel-query-builder laravel-8
我有PurchaseOrderProduct模型从中获取类似的数据
PurchaseOrderProduct::with('products')
->with('warehouse_locations')
->with('productStatuses')
->with('purchase_orders')
->where('product_id', $request->product_id)
->where('free_qty', '>=', 1)
->get();
Run Code Online (Sandbox Code Playgroud)
现在在这个表中,我有一个expiry_date类型的列datei想要获取orderBy expiry_date最接近当前日期的数据。
意味着purchase_order_product到期日期最接近当前日期的应该排在第一位。
$product = PurchaseOrderProduct::with('products')
->with('warehouse_locations')
->with('productStatuses')
->with('purchase_orders')
->where('product_id', $request->product_id)
->where('free_qty', '>=', 1)
->whereDate('expiry_date', '>', Carbon::now())
->orderBy('expiry_date','asc')
->get();
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
2750 次 |
| 最近记录: |