Esempio n. 1
0
 /**
  * Remove the specified resource from storage.
  *
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function destroy($id)
 {
     Team::destroy($id);
     return redirect('admin/team');
 }
Esempio n. 2
0
 /**
  * Allow user to leave team
  *
  * @return \Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector
  */
 public function leave()
 {
     $user = \Auth::user()->with(['team', 'team.members'])->first();
     $team_id = $user->team->id;
     // Remove user's team
     $user->team_id = null;
     $user->save();
     \Log::debug("User removed from team {$team_id}");
     // Clean up team if no more users
     if (count($user->team->members) - 1 == 0) {
         Team::destroy($team_id);
         \Log::info("Team {$team_id} deleted.");
     }
     return redirect('/');
 }