Replies: 2 comments
-
That is ok, and it is not the problem, for assign the role you need to set the team_id on the running instance, read here |
Beta Was this translation helpful? Give feedback.
-
Adding this to middleware did not resolve the issue. I had to do a couple of things to get the seeder to work. Create a couple of migrations. After that Spatie roles keep returning that Role id 1 did not exist, but I checked the roles table and the seeder did create 3 roles. I split the SpatieDemoSeeder into two seeders. The first seeder made the permission, roles, and users. The second migration assign the role with id 1 to user. This did not work ether. It would always fail at |
Beta Was this translation helpful? Give feedback.
-
Integrity constraint violation: 1048 Column 'team_id' cannot be null (SQL: insert into model_has_roles (model_id, model_type, role_id, team_id) values (1, App\Models\User, 1, ?))
I am getting this error when I try to run the demoseeder with teams => true in the configuration. The first user gets created and when it comes to assign the role the error happens. I tried to assign the id like Role::create(['name' => 'reader', 'team_id' => 1]); during creation but same error. What can I do to fix this ?
Beta Was this translation helpful? Give feedback.
All reactions