Crinsane/LaravelShoppingcart – Model not associating correctly or empty

I was having the exact same issue, using the most recent version 2.3.0.

Cart::add($product->uid, $product->name, $qty, $product->price)->associate('App\Models\Product');

In a foreach in my view, dd($product->model) returns null.

When try $this->cart->add($product->id, $product->title, 1, $product->price)->associate(‘App\Models\Product’);

works perfectly, primary key of product table has to placed in id. In my case I have id as primary key and uid as unique in product table.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s