drehimself / laravel-ecommerce-example

Code for YouTube series on building a Laravel E-Commerce application.
https://www.youtube.com/watch?v=o5PWIuDTgxg&list=PLEhEHUEU3x5oPTli631ZX9cxl6cU_sDaR
1.01k stars 585 forks source link

Trying to get property 'image' of non-object #108

Open junmingyeo opened 3 years ago

junmingyeo commented 3 years ago

Hi, I am currently facing an issue where I click proceed to checkout using a user account that are not in my first entry in the user table. I am unable to load the checkout page and with an error message " Trying to get property 'image' of non-object".

When I use guest checkout or the user account of the first entry of my user table, I have no such issues and I am able to do my checkout and all.

Does anyone have any idea what is causing this?

blwsh commented 3 years ago

Could be something to do with https://github.com/drehimself/laravel-ecommerce-example/blob/983ed292933fab690c9448f5e66fb0aaa37c93c8/resources/views/checkout.blade.php#L136-L152

Maybe try wrapping checkout-table-row in:

@if($item->model)
...
@endif

If this fixes your problem there's likely still an underlying issue such as a missing foreign key.