app/Http/Controllers/CartController.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)
    {
        $product_img = Product::where('id', $request->id)->pluck('img_url');
        Cart::instance(Auth::user()->id)->add(
            [
            'id' => $request->_token, 
            'name' => $request->name, 
            'qty' => $request->qty,
            'price' => $request->price, 
            'weight' => $request->weight,
            'options'=> ['product_id'=> $request->id, 'img_url'=>$product_img]
            ] 
        );
        return redirect()->route('carts.index');
    }
public function store ( Request $ request ) { $ product_img = Product :: where ( 'id' , $ request -> id ) -> pluck ( 'img_url' ) ; Cart :: instance ( Auth :: user ( ) -> id ) -> add ( [ 'id' => $ request -> _token , 'name' => $ request -> name , 'qty' => $ request -> qty , 'price' => $ request -> price , 'weight' => $ request -> weight , 'options' => [ 'product_id' => $ request -> id , 'img_url' => $ product_img ] ] ) ; return redirect ( ) -> route ( 'carts.index' ) ; }
Store a newly created resource in storage.
Store a newly created resource in storage .