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

clat23's avatar

Adding to team_users relationship

I have created a new Laravel Spark app with the --team-billing flag. This has created a users table, teams table and team_users table. All is well with this many-to-many relationship between teams and users. (https://spark.laravel.com/docs/8.0/teams)

I need to create a parent model. A parent can have many teams, but a team can only have one parent. I understand this is a one-to-many relationship.

I have also opted to create additional roles: owner, admin, member (https://spark.laravel.com/docs/8.0/teams#team-roles)

I have four questions:

  1. How can I create a relationship wherein the user inherits the parent via its team?
  2. How can I limit a user with a member role to see data only for its team?
  3. How can I allow a user with an admin role to see all data of all teams within its parent?
  4. How can I allow a user with an owner role to see all data of all parents teams?
0 likes
0 replies

Please or to participate in this conversation.