app/Http/Controllers/OrdersController.php
/**
     * Store a newly created resource in storage.
     *
     * @param  \Illuminate\Http\Request  $request
     * @return \Illuminate\Http\Response
     */
Store a newly created resource in storage.
Store a newly created resource in storage .
public function store(Request $request)
    {
        if(auth()->user()->isClient()){
            $order = new Order;
            $order->user_id = auth()->user()->id;
            $order->status = 0;
            $order->save();
            session(['current_order' => $order->id]);
            return redirect('/');
        }
        else abort(404);
    }
public function store ( Request $ request ) { if ( auth ( ) -> user ( ) -> isClient ( ) ) { $ order = new Order ; $ order -> user_id = auth ( ) -> user ( ) -> id ; $ order -> status = 0 ; $ order -> save ( ) ; session ( [ 'current_order' => $ order -> id ] ) ; return redirect ( '/' ) ; } else abort ( 404 ) ; }
Store a newly created resource in storage.
Store a newly created resource in storage .
// Create new order // Set session and redirect