我不知道如何使用Order::with原始查询获取数据,我想$order使用Where($query).
public function getOrders()
{
$order = Order::with([
'menu:id,name,image_url,created_by',
'created_user:id,name,email,avatar',
'menu.created_user:id,name,email,avatar',
'menu.categories'
])->get();
$query = 'SELECT * FROM orders WHERE (now() >= start_at OR start_at IS NULL) AND (now() <= end_at OR end_at IS NULL)';
$currentOrder = DB::select(DB::raw($query));
return $currentOrder;
}
慕后森