Laravel - Property [title] does not exist on this collection instance

When you’re using get() you get a collection. In this case you need to iterate over it to get properties:

@foreach ($collection as $object)
{{ $object->title }}
@endforeach
Or you could just get one of objects by it’s index:

{{ $collection[0]->title }}
Or get first object from collection:

{{ $collection->first() }}
When you’re using find() or first() you get an object, so you can get properties with simple:

{{ $object->title }}

 

https://stackoverflow.com/questions/41366092/laravel-property-title-does-not-exist-on-this-collection-instance

    原文作者:思考的大腿
    原文地址: https://www.cnblogs.com/thinkingthigh/p/6894255.html
    本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系博主进行删除。
点赞