Nikki
305
7
Laravel

Not sure how to get 3 months

Posted 5 months ago by Nikki

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 sign in or create an account to participate in this conversation.