vendredi 1 mars 2019

Laravel Crinsane/LaravelShoppingcart associate() doesn't work

In my Laravel I'm using this shoppingcart .

When i add one product to my shopping cart i wan to have associate() with App\Product Model .

This is my code :

  public function store(Request $request)
{
    // store product information to Cart


    Cart::add($request->id, $request->name, 1, $request->price)
    ->associate('App\Product');


    return redirect(route('cart.index'))->with('success_message','محصول با موفقیت به سبد اضافه شد');
}

But when i want to access model $item->model->id in view I get this error :

Trying to get property 'id' of non-object (View: C:\xampp\htdocs\digikala\resources\views\cart.blade.php)



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire