Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added function createOwnedTeam to UserHasTeams #155

Merged
merged 3 commits into from
Mar 24, 2023

Conversation

khatriafaz
Copy link
Contributor

Added a new function createOwnedTeam to the UserHasTeams trait, which can allow the developers to quickly implement the team creation without repeating 4-5 lines of code.

The existing process for doing this is something like this:

$team = Team::create(['name'=> 'My team', 'owner_id' => $user->id]));

$user->attachTeam($team);

// If user already have any other current team, we have to separately switch team
$user->switchTeam($team);

The new function does all this behind the scenes:

// If this is first team of user, user's current team will be this new team
$team = $user->createOwnedTeam(['name' => 'My awesome team']);

// If the user has teams, we want the user to switch to this new team, pass second parameter true to this method.
$team = $user->createOwnedTeam(['name' => 'My awesome team'], true);

@neerajsohal
Copy link

Is this merged? Both functions are quite useful during the onboarding process. Would love to see this get added. I will update the package in https://github.com/electrikhq/electrik/

Best,
Neeraj

@okaufmann okaufmann merged commit 46da329 into mpociot:master Mar 24, 2023
@okaufmann
Copy link
Collaborator

done 🎉 Thanks for your contribution @khatriafaz

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants