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

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

        event(new DeletingTeam($team));

        $team->users()->where('current_team_id', $team->id)
                        ->update(['current_team_id' => null]);

        $team->users()->detach();

        $team->delete();

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

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

        event(new DeletingTeam($team));

        $team->users()->where('current_team_id', $team->id)
                        ->update(['current_team_id' => null]);

        $team->users()->detach();

        $team->delete();

        return $this->teams->getAllTeamsForUser($user);
    }
public function destroy ( Request $ request , $ teamId ) { $ user = $ request -> user ( ) ; $ team = $ request -> user ( ) -> teams ( ) -> where ( 'owner_id' , $ user -> id ) -> findOrFail ( $ teamId ) ; event ( new DeletingTeam ( $ team ) ) ; $ team -> users ( ) -> where ( 'current_team_id' , $ team -> id ) -> update ( [ 'current_team_id' => null ] ) ; $ team -> users ( ) -> detach ( ) ; $ team -> delete ( ) ; return $ this -> teams -> getAllTeamsForUser ( $ user ) ; }
Destroy the given team.

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