On the User.php model I have the following relationship:
public function roles()
{
return $this->belongsToMany(Role::class);
}
In the database, I have different roles and basically I want to return all the roles, except the "superadmin" role so that it cannot be displayed in the views or wherever I will choose to show the roles.
I've tried something like:
public function roles()
{
return $this->belongsToMany(Role::class)->where('name', '!=', 'superadmin');
}
... but it doesn't work. I assume it has something to do with the pivot table. I also tried this:
public function roles()
{
return $this->belongsToMany(Role::class)->where('role_id, '!=', $id);
}
Any idea how to do this or if it's even possible?
Thanks!