Level 104
This should give you the basic idea:
$from = now();
$to = $from->copy()->addMonths(3);
Order::whereBetween('created_at', [$from, $to])->get();
I'm trying to create a sort function where if it's selected it will display the necessary amount of orders. For example if the user selects to display orders from the lat 3 months then that needs to be displayed.
At the moment I'm stuck at the section where I say it's 3 monts
public function trackOrders()
{
$menus_child = Menu::where('menu_id', 0)->with('menusP')->get();
$contacts = Contact::all();
$orders = Auth::user()->orders->sortByDesc('order_date');
$orders->transform(function($order, $key){
$order->cart = unserialize($order->cart);
return $order;
});
$from = Carbon\Carbon::now('+2:00');
// This is where I'm stuck
$to =
$three_months = Order:: where($from, '>', $to);
return view('public.users.track-orders', compact('menus_child', 'contacts', 'orders', 'order_item'));
}
Please or to participate in this conversation.