//这是我的控制器`
公共函数索引($id){
$users=User::where('id',$id)->get();
return view('user',compact('users'));
}
}`
//这是我的用户模型
public function getPosts()
{
return $this->hasMany('App\Post','user_id','id');
}
//这是我的用户刀片
@foreach($user->getPosts as $post)
<div class="profile-content">
<section class="post-heading">
<div class="rows">
<div class="col-md-11">
<div class="media">
<div class="media-left">
<a href="#">
<img class="media-object photo-profile" src="https://scontent.fgyd4-2.fna.fbcdn.net/v/t1.0-9/p960x960/73248174_2597397730318615_6397819353256951808_o.jpg?_nc_cat=109&_nc_sid=7aed08&_nc_ohc=VxH_cAqJ778AX_7B97W&_nc_ht=scontent.fgyd4-2.fna&_nc_tp=6&oh=e5b02c7f91818664cf253e71f2ddf106&oe=5F5F4E74" width="40" height="40" alt="...">
</a>
</div>
<div class="media-body">
<a href="/users" class="anchor-username"><h4 class="media-heading">{{$user->name}} </h4></a>
<a href="#" class="anchor-time">{{$user->$post['created_at']}}</a>
</div>
</div>
</div>
<div class="col-md-1">
<a href="#"><i class="glyphicon glyphicon-chevron-down"></i></a>
</div>
</div>
</section>
<section class="post-body">
<p>{{ $user->getPost->post['post_description'] }}</p> <!-- i stick around here -->
</section>
//它给了我这个错误
此集合实例上不存在属性 [getPosts]。(查看:C:\xampp\htdocs\site\resources\views\user.blade.php)
慕婉清6462132
哆啦的时光机
临摹微笑
蝴蝶不菲