asignRole in filament-shield
Hi everyone,
I'm facing an issue with Spatie Laravel Permission. I'm trying to assign a role to a user after syncing data from another database. The user is created or updated successfully, but the assignRole method doesn't seem to work — no roles are assigned, and nothing is written to the model_has_roles table.
What I've Tried:
User model uses HasRoles trait.
Role user exists in the roles table.
Queue worker is running properly.
Ran php artisan permission:cache-reset.
Added logging after assignRole, but no logs appear.
4 Replies
Are you using teams in the permissions, if so you need to run:
setPermissionsTeamId(TeamID HERE);
Is the Job being run? php artisan queue:work?
Yes, the job running with queue:work
Hmm, sorry I havent hear about "teams in permission", in my app the role is basic, so user only can have 1 role (super_admin, admin, user), I also using filament-shield so I can handle permission based on their role
@toeknee
So the fact not logs get set... shows you hvae a bigger issue, log if the forech is ever being run firstly.