teams icon indicating copy to clipboard operation
teams copied to clipboard

[question] Personal teams?

Open shahzeb1 opened this issue 1 year ago • 2 comments

Hi thank you for the package. This isn't an issue but rather a discussion question.

How should I think about a user's personal team? For instance, in most products (like Notion) a user signs up and has a "personal" project (or team). How can we assign items to a specific user (who is teamless)?

shahzeb1 avatar Dec 06 '24 05:12 shahzeb1

Hi thank you for the package. This isn't an issue but rather a discussion question.

How should I think about a user's personal team? For instance, in most products (like Notion) a user signs up and has a "persona" project (or team). How can we assign items to a specific user (who is teamless)?

Hello! This is an interesting question. The core idea behind the approach I followed is to work with "teams," where it’s assumed that each user belongs to a team. All functionality is strictly tied to this concept.

That said, there are a couple of potential solutions:

  1. Automatically Create a Team at Registration

Upon user registration, a team can be created where the user is designated as the owner. This is currently implemented using the user_id key in the main team entity. No additional actions are required. If needed, you can restrict adding other users to this team or granting them permissions.

  1. Avoid Creating Teams Entirely

Alternatively, you can skip creating teams and instead bind the necessary entities directly to the user using custom logic. In this case, the package’s team-related functionality would be bypassed, and you’d need to manually handle all access rights.

If you have any other suggestions on how this issue could be resolved differently, I’m always open to new ideas and initiatives!

Jurager avatar Dec 06 '24 17:12 Jurager

Thanks for the quick response! Option 1 (create a "Personal team" for the user) seems like better suggestion. This is based on the fact that if we have some arbitrary model (let's say Podcast) that can belong to either a User or a Team, then things will get hairy. Having to check permission depending on the type of owner model just seems like a recipe for accidental slipups.

From the Laravel Jeatstream docs:

Jetstream's team features allow each registered user to create and belong to multiple teams. By default, every registered user will belong to a "Personal" team. For example, if a user named "Sally Jones" creates a new account, they will be assigned to a team named "Sally's Team". After registration, the user may rename this team or create additional teams.

I think there's presidence set here by the benevolent gods of a first-party Laravel package, so maybe that is the "best" way. 🤷

shahzeb1 avatar Dec 07 '24 02:12 shahzeb1

I see there's a $user->teams, so I suppose the user can be member of multiple teams. Then why isn't there a $user->currentTeam so we can set the scope of all models managed by that team?

I'm looking for an alternative to Larevel Jetstream (with the teams option)...

Thanks.

MGeurts avatar Apr 15 '25 08:04 MGeurts

I see there's a $user->teams, so I suppose the user can be member of multiple teams. Then why isn't there a $user->currentTeam so we can set the scope of all models managed by that team?

I'm looking for an alternative to Larevel Jetstream (with the teams option)...

Thanks.

In current implementation we are using middleware to check the user team without need for every time changing the teams. Middleware impose some restrictions on how your application should behave, but we tried to make them as flexible as possible so that everyone could customize them for themselves. We are not currently planning to implement the team switching functionality, as the logic will become much more complicated, since we also cannot abandon the option of checking through middleware

Jurager avatar Sep 04 '25 13:09 Jurager