1. 第一个Model是User 第一个Model也是User
2. 关系表名是 'followers'
/**
* 关注当前用户的
* @return \Illuminate\Database\Eloquent\Relations\BelongsToMany
*/
public function followers()
{
return $this->belongsToMany(self::class, 'followers', 'followed_id','follower_id')->withTimestamps()
->withTimestamps();
}
/**
* 被当前用户关注的用户
*/
public function followed()
{
return $this->belongsToMany(self::class, 'followers', 'follower_id', 'followed_id');
}