多对多关系不应该三个表吗,怎么就一个 users 表和一个中间表 followers,粉丝表 follower 怎么没有,如果没有怎么进行连接呢?
<?php
namespace App\Models;
.
.
.
class User extends Authenticatable
{
.
.
.
public function followers()
{
return $this->belongsToMany(User::Class, 'followers', 'user_id', 'follower_id');
}
public function followings()
{
return $this->belongsToMany(User::Class, 'followers', 'follower_id', 'user_id');
}
}
推荐文章: