Laravel 基本关系提供错误属性[post]不存在

Laravel 基本关系提供错误属性[post]不存在,laravel,laravel-5.4,Laravel,Laravel 5.4,在我的应用程序中,我有用户和帖子。和用户有追随者。followers表定义为: user_id follower_id function posts(){ return $this->hasMany('App\Posts', 'id', 'user_id'); } 如果我的用户模型有这种关系,那么我就可以得到以下用户和追随者: function followers() { return $this->belongsToMany('App\User', 'follow

在我的应用程序中,我有用户和帖子。和用户有追随者。followers表定义为:

user_id
follower_id
function posts(){
   return $this->hasMany('App\Posts', 'id', 'user_id');
}
如果我的用户模型有这种关系,那么我就可以得到以下用户和追随者:

function followers()
{
    return $this->belongsToMany('App\User', 'followers', 'user_id', 'follower_id');
}

function follows()
{
    return $this->belongsToMany('App\User', 'followers', 'follower_id', 'user_id');
}
在用户控制器中,我尝试使用访问以下内容:

$follows = $authed->follows;
这很好,但我尝试访问该用户的帖子。 用户模型中有一个关系,定义为:

user_id
follower_id
function posts(){
   return $this->hasMany('App\Posts', 'id', 'user_id');
}
但当我尝试访问帖子时:

$follows = $authed->follows;
$followingPosts = $follows->posts->orderBy('id', 'desc')->take(10)->get();

它给了我一个错误:属性[posts]在此集合实例上不存在。
$follows=$authed->follows
用户
对象的
集合,而不是单个对象,这就是为什么会出现错误的原因

,但当我尝试在foreach中获取$follows->posts as post时,它仍然不起作用。