Replies: 1 comment 1 reply
-
Maybe I don't fully understand the reason for doing something like this, but if you want to assign roles to the team model, there should be a guard that uses that model, and the roles must have that guard on guard_name |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
I am using the package with the teams feature enabled. Assigning roles to users works fine. But we would like the teams to have each a (set of) role(s), so that every user that is assigned to a team, automatically is assigned the roles that belong to that team.
Since the pivot table is asking for 'model' data instead of 'user' data, I tried to use the team as that 'model'. So I added the 'HasRoles' trait to the teams model and did something like:
$team->assignRole($role);
Then I got this error message:
App\\Models\\Team::getStoredRole(): Return value must be of type Spatie\\Permission\\Contracts\\Role, Illuminate\\Database\\Eloquent\\Builder returned
The controller uses 'Spatie\Permission\Models\Role'.
If I try the same via tinker, I get this error message:
Spatie\Permission\Exceptions\GuardDoesNotMatch The given role or permission should use guard `` instead of
web.
Is it possible to use the existing methods to assign a role to a team instead of a user, or should I already look for other ways to implement that?
Thanks in advance!
Beta Was this translation helpful? Give feedback.
All reactions