Reputation: 373
Let me put the code first..
class Permission extends Model {
public function roles()
{
return $this->belongsToMany('App\Role');
}
public function menus()
{
return $this->belongsTo('App\Menu');
}
}
class Role extends Model {
public function users()
{
return $this->hasMany('App\User');
}
public function permissions()
{
return $this->belongsToMany('App\Permission');
}
}
class Menu extends Model {
public function permissions()
{
return $this->hasMany('App\Permission');
}
}
class User extends Authenticatable {
public function role()
{
return $this->belongsTo('App\Role');
}
}
Well,
I'm trying to get something like (assuming that I already got a single user) $user->role->permissions->menus
I'm trying to get role, then the permissions associated with that role and then the menu items that are associated with that permissions.
Idk if i'm explaining myself..
Upvotes: 2
Views: 37