Replies: 18 comments 11 replies
-
Only when teams are enabled
|
Beta Was this translation helpful? Give feedback.
-
@erikn69 What if we want to set a Super Admin across the site, without having to set the super admin for every team.. what would you recommend? |
Beta Was this translation helpful? Give feedback.
-
it is not a bug
you have to customize migration(#1980) and relation roles on User model with laravel-permission/src/Traits/HasRoles.php Lines 57 to 62 in 6a3ed62 |
Beta Was this translation helpful? Give feedback.
-
We're also interested in this feature! |
Beta Was this translation helpful? Give feedback.
-
@haleyngonadi just add a field on user's table like Gate::before(function ($user, $ability) {
return $user->is_admin ? true : null;
}); https://spatie.be/index.php/docs/laravel-permission/v5/basic-usage/super-admin |
Beta Was this translation helpful? Give feedback.
-
I took this to be a bug at first simply because the behavior is not what you expect from this portion of the docs: See #Roles Creating
// with null team_id it creates a global role, global roles can be assigned to any team and they are unique
Role::create(['name' => 'writer', 'team_id' => null]);
// creates a role with team_id = 1, team roles can have the same name on different teams
Role::create(['name' => 'reader', 'team_id' => 1]);
// creating a role without team_id makes the role take the default global team_id
Role::create(['name' => 'reviewer']); But when you attempt to assign the role you run into the error mentioned above. However, if you read ahead a little further the docs explain that the |
Beta Was this translation helpful? Give feedback.
-
Any update? Hope this could be fixed. |
Beta Was this translation helpful? Give feedback.
-
Is a expected behaivor |
Beta Was this translation helpful? Give feedback.
-
For anyone looking for a solution, not sure how this breaks the functionality as you'll need to ensure that you
|
Beta Was this translation helpful? Give feedback.
-
Seems like we should create a "Global Team". When you create a new user or when a user registers, this user would be assigned to the global team as well as a personal team. I know I was trying to figure out how to prevent a user from having a personal team but still see global assets. I think this would solve my issue. When the package is installed a question could be asked "Do you need a 'Global Team?" The global_team_id could be recorded in the permissions.php config file or as their personal team. |
Beta Was this translation helpful? Give feedback.
-
I'm running into the same issue. I need roles and permissions both at the team level and at the global level. In fact, I actually need roles at three different levels. It would be great if this could be supported. |
Beta Was this translation helpful? Give feedback.
-
@lukebouch you can overwrite everything you need |
Beta Was this translation helpful? Give feedback.
-
@erikn69 ok. I will try that. You said it might break other things. What might it break? |
Beta Was this translation helpful? Give feedback.
-
I would not be able to answer that, because you will have your own code, with a functionality that is not what was expected, only you could check that it was broken, maybe run the tests with your changes |
Beta Was this translation helpful? Give feedback.
-
Alright, so I came across a similar scenario. Since we are all for workarounds, here's what I did Using multiple guards and assuming the admin area is different from the user area To get 2 types of users, users with team roles and users with global roles,
` config('permission.table_names.model_has_roles'),
` This way, if you ever assign someone a global role with a team_id, you can check for permissions of that global role regardless of team_id set on model_has_roles table I think I'm forgetting some things, and I did this just recently, so I've not totally tested it. But it shows promising results, though If I see something I missed, I'll try my best to answer If you have questions feel free to shoot. And yes I know this approach isn't for everyone bit it's a good way to categorise roles Checkout spatie multi auth part of the tutorial for drawbacks, which I my case proves to be an absolute win |
Beta Was this translation helpful? Give feedback.
-
set teams by false in config\permission.php 'teams' => false, |
Beta Was this translation helpful? Give feedback.
-
|
Beta Was this translation helpful? Give feedback.
-
Hi.
I read all of the following issues carefully several times and applied them all to my project, but I still have the same problem:
https://spatie.be/docs/laravel-permission/v5/basic-usage/super-admin
https://spatie.be/docs/laravel-permission/v5/basic-usage/teams-permissions#working-with-teams-permissions
#1840
#1845
#1853
#1855
#1893
I think this problem is a bug Or that the spatie/laravel-permission document is incomplete.
please help me!
Beta Was this translation helpful? Give feedback.
All reactions