Alright so I have been looking for hours for an answer but can't seem to find one. I have an array of "orders" all for different dates. I get all of the orders for this week, this should not be an issue, then I want to a tab for each day of the week.
到目前为止,我try 的是:
$dinnerOrders->where('date','>',$date)->where('date','<', $date->endOfDay())->sortBy('created_at');
其中$date是:
$dt = Carbon\Carbon::create()->startOfWeek();
Carbon\Carbon::setTestNow($dt);
$date = new Carbon\Carbon('this ' . $day);
和$DinnerOrders勉强度日:
$dinnerOrders = collect([]);
foreach($restaurant->dinners as $dinner) {
foreach($dinner->orders as $order) {
$dinnerOrders[$order->id] = $order;
}
}
日期看起来是正确的,而且它是用SQL写的.这不起作用是因为$dinnerOrders是一个集合吗?
我得到的是什么,也就是一个空集,尽管它在MySQL终端上工作.
So what I'm asking is perhaps, can you do a date comparison on a collection? If so, how?