I have 3 models:
- User
- Role
- Permission
Note:
- a user can have direct permissions
- a role can have permissions
- a user can have roles
I'm trying to get the total permissions a user has, either through their direct permissions or through their roles permissions. So I need to combine both into 1 collection and count the total.
I've set up the belongsToMany relationships for User
and Role
:
public function permissions()
{
return $this->belongsToMany('App\Permission');
}
How do I do this?