Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

secondman's avatar

Assigning Team Roles in UserFactory

I'm attempting to replace the built in roles in Jetstream with Spatie laravel-permission team roles.

Their documentation leaves a lot to be desired where it comes to the teams implementation so I feel like I have my work cut out for me. =)

  1. So first off, how can I assign roles (which must include a team id) within the UserFactory? I'm initially trying to accomplish this in the withPersonalTeam method, but I'm not having any luck so far. I looked into the boot creation method provided in their docs, and that seem like it would work for logged in users, but obviously we can't access a User in the Team model when no one is logged in.

  2. When creating new users during normal registration, would I create a new role for their personal team? Or simply assign them to the existing admin role with their personal team id?

If anyone has a working implementation to share that would be ideal.

Thanks

0 likes
0 replies

Please or to participate in this conversation.