I am trying to create a Collection and pass it to blade. My PHP code look like this
I want to show my records on my category page. But I'm faced with a problem. I'm sorry for my bad English. Error: Property movies does not exist on this collection instance.
In my blade I loop through people_col
to get properties of items:
However I got this error:
Property [name] does not exist on this collection instance
Any idea?Thanks
2 Answers
You are creating a collection of collections where you should have created a collection of objects instead.
With your current implementation you should be able to get the values using array access method {{ $people['name'] }}
or using get
method on collection {{ $people->get('name') }}
If you created a collection of objects like below and return it instead of what you are doing now
Then in your view you should be able to access people object like you have done in your code.
Try to access to the property name this way: $people['name']