public function leaveTeam(Request $request, $teamId)
    {
        $user = $request->user();

        $team = $user->teams()
                    ->where('owner_id', '!=', $user->id)
                    ->where('id', $teamId)->firstOrFail();

        $team->removeUserById($user->id);

        return $this->teams->getAllTeamsForUser($user);
    }
public function leaveTeam(Request $request, $teamId)
    {
        $user = $request->user();

        $team = $user->teams()
                    ->where('owner_id', '!=', $user->id)
                    ->where('id', $teamId)->firstOrFail();

        $team->removeUserById($user->id);

        return $this->teams->getAllTeamsForUser($user);
    }
public function leaveTeam ( Request $ request , $ teamId ) { $ user = $ request -> user ( ) ; $ team = $ user -> teams ( ) -> where ( 'owner_id' , '!=' , $ user -> id ) -> where ( 'id' , $ teamId ) -> firstOrFail ( ) ; $ team -> removeUserById ( $ user -> id ) ; return $ this -> teams -> getAllTeamsForUser ( $ user ) ; }
Remove the user from the given team.

@param  \Illuminate\Http\Request  $request
@param  string  $teamId
@return \Illuminate\Http\Response
Remove the user from the given team .