/** * Display a listing of the resource. * * @return Response */ public function index($team) { $team = Teams::getByAbbrev($team)->first(); $playersWithPosition = []; foreach ($team->players as $player) { $player->position = $player->position()->first()->name; $player->team = $player->team()->first()->city . " " . $player->team()->first()->name; $playersWithPosition[] = $player; } return response()->json($playersWithPosition); }
/** * Remove the specified team from the database. * * @param integer, $id, The id off the team in the database. */ public function destroy($id) { Teams::destroy($id); session()->flash('message', 'Team successfully deleted'); return redirect()->back(); }
/** * Show the form for editing the specified resource. * * @param $id * * @return */ public function edit($id) { $data['user'] = User::findOrFail($id); $data['departments'] = Departments::all(); $data['teams'] = Teams::all(); $data['countries'] = Countries::all(); $data['roles'] = Role::all(); return view('staff/edit_user', $data); }
public static function getByAbbrev($abbrev) { return Teams::where('abbrev', '=', $abbrev); }
/** * Display a listing of the resource. * * @return Response */ public function index() { $teams = Teams::all(); return response()->json($teams); }