我有3张桌子; 用户,组和权限
在模型中,我在用户模型中将关系设置为belongsToMany:
public function groups() {
return $this->belongsToMany('Group');
}
Run Code Online (Sandbox Code Playgroud)
在组模型中:
public function users() {
return $this->belongsToMany('User');
}
public function permissions() {
return $this->belongsToMany('Permission');
}
Run Code Online (Sandbox Code Playgroud)
在权限模型中:
public function groups() {
return $this->belongsToMany('Group', 'id');
}
Run Code Online (Sandbox Code Playgroud)
许多用户 - 对许多组 - 许多组 - 对许多权限
我正在尝试获取用户拥有的所有权限,并且不知道它的代码应该是什么样子.有人可以帮忙吗?