Skip to content

Commit

Permalink
Documented the function createOwnedTeam
Browse files Browse the repository at this point in the history
  • Loading branch information
khatriafaz committed Mar 7, 2023
1 parent fdb2be5 commit 5f45995
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,18 @@ $user->teams()->attach($team->id); // id only

By using the `attachTeam` method, if the User has no Teams assigned, the `current_team_id` column will automatically be set.

Alternatively, you can also use `createOwnedTeam` method from `UserHasTeams` trait. It will create team for the user as owner, attach the user to the team and switch to the newly created team.

```php
// Create user owned team and switch the current team to this new team.
$team = $user->createOwnedTeam(['name' => 'My awesome team']);

// If user has another current team active, you should pass second parameter as true to force switch to the new team.
$team = $user->createOwnedTeam(['name' => 'My awesome team'], true);
```

The function will return the newly created instance of your team model.

### Get to know my team(s)

The currently assigned Team of a user can be accessed through the `currentTeam` relation like this:
Expand Down

0 comments on commit 5f45995

Please sign in to comment.