Mpociot\Teamwork\Traits\UserHasTeams::detachTeam PHP Method

detachTeam() public method

Alias to eloquent many-to-many relation's detach() method.
public detachTeam ( mixed $team )
$team mixed
    public function detachTeam($team)
    {
        $team = $this->retrieveTeamId($team);
        $this->teams()->detach($team);
        event(new UserLeftTeam($this, $team));
        if ($this->relationLoaded('teams')) {
            $this->load('teams');
        }
        /**
         * If the user has no more teams,
         * unset the current_team_id
         */
        if ($this->teams()->count() === 0 || $this->current_team_id === $team) {
            $this->current_team_id = null;
            $this->save();
            if ($this->relationLoaded('currentTeam')) {
                $this->load('currentTeam');
            }
        }
        return $this;
    }