Property [title] does not exist on this collection instance
(View: C:\phpstudy\WWW\laravel54\resources\views\user\show.blade.php)
@foreach($posts as $post)
<div class="blog-post" style="margin-top: 30px">
<p class=""><a href="/user/{{$post->user->id}}">{{$post->user->name}}</a>{{$post->created_at->diffForHumans()}}</p>
<p class=""><a href="/posts/{{$post->id}}" >{{$post->title}}</a></p>
<p><p>{!! str_limit($post->content,100,'...')!!} </p>
</div>
@endforeach
以上才是正确的。
报错是因为写成了{{$posts->user->id}}。
本作品采用《CC 协议》,转载必须注明作者和本文链接
推荐文章: