/** * Display a listing of the resource. * * @return Response */ public function index() { $teams = Team::get(); if (empty($teams)) { return redirect()->route('teams.index')->with('message', 'Najpierw dodaj Druzyne.'); } $positions = PlayerPosition::get(); if (empty($positions)) { return redirect()->route('teams.index')->with('message', 'Najpierw dodaj pozycje.'); } $players = Player::orderBy('ID_PILKARZ', 'desc')->paginate(10); return view('players.index', compact('players'))->with('positions', self::getPositions($positions))->with('teams', self::getTeams($teams)); }
/** * Show Manage Page of Players. * * @param Request $request * @return \Illuminate\Http\Response */ public function players(Request $request) { $page = $request->input('page', 1); $filter = $request->input('filter', ''); $q = $request->input('q', ''); if ($filter == "") { $players = Player::orderBy('uid'); } elseif ($filter == "player_name") { $players = Player::like('player_name', $q)->orderBy('uid'); } elseif ($filter == "uid") { $players = Player::where('uid', $q)->orderBy('uid'); } $total_pages = ceil($players->count() / 30); $players = $players->skip(($page - 1) * 30)->take(30)->get(); return view('admin.players')->with('players', $players)->with('filter', $filter)->with('q', $q)->with('page', $page)->with('total_pages', $total_pages); }