app/Http/Controllers/CartController.php
/**
     * Display a listing of the resource.
     *
     * @return \Illuminate\Http\Response
     */
Display a listing of the resource.
@return \Illuminate\Http\Response
Display a listing of the resource . @return \ Illuminate \ Http \ Response
public function index()
    {
        if (session('carrito')) {
           $var=session('carrito');
        foreach ($var as $id) {
            $producto=Product::find($id);    
            $productos[]=$producto;
        }
        return view('shop/cart', compact('productos'));  
        }
        else {
            return redirect('shop/index');
        }
    }
public function index ( ) { if ( session ( 'carrito' ) ) { $ var = session ( 'carrito' ) ; foreach ( $ var as $ id ) { $ producto = Product :: find ( $ id ) ; $ productos [ ] = $ producto ; } return view ( 'shop/cart' , compact ( 'productos' ) ) ; } else { return redirect ( 'shop/index' ) ; } }
Display a listing of the resource.
Display a listing of the resource .