Do you have the full error trace? Just Trying to get property 'id' of non-object error is really unclear and can happen in many different places. It's probably going wrong in the view. Maybe you can show a bit about that as well?
Trying to get property 'id' of non-object error (Asset management system)
This error has been haunting me for days, the whole project has been fully functional except for the create feature. When I'm logged on as a regular user, i can view the index of the clothes without any problem. But when logged on as an admin, i can only view the index when i create a new clothe for the first time (which regular user doesn't have access to). After that first time, the second time I add a new clothe, this error pops up, and I'm losing my mind trying to figure this out. I'm just starting out with laravel and my project deadline is tomorrow :( Hope somebody can help..
This is the code inside my index function on the controller:
$clothe = Clothe::all();
return view('clothes.index')->with('clothe',$clothe)->with('brand',Brand::all())->with('stock',Stock::all());
The brand pertains to the brand model which is the brands of clothing, while stock is the stock model which pertains to 2 pieces of data, 'Available' and 'Not Available' (take note this works when I'm only logged in as a regular user, but doesn't when I create a second clothe as an admin)
On my clothes index blade, for some reason it reads $brand, $stock and $clothe as non objects.
When the admin creates the second clothing, the data does get stored as I have checked in my database, the only problem is displaying it. Thank you for reading.
Please or to participate in this conversation.