/** * 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.'); } $judges = Judge::get(); if (empty($judges)) { return redirect()->route('judges.index')->with('message', 'Najpierw dodaj sedziego.'); } $champions = Championship::get(); if (empty($champions)) { return redirect()->route('championships.index')->with('message', 'Najpierw dodaj rozgrywki.'); } $arenas = Arena::get(); if (empty($arenas)) { return redirect()->route('arenas.index')->with('message', 'Najpierw dodaj stadion.'); } $games = Game::orderBy('ID_MECZ', 'desc')->paginate(10); return view('games.index', compact('games'))->with('teams', self::getTeams($teams))->with('judges', self::getJudges($judges))->with('champions', self::getChampionship($champions))->with('arenas', self::getArena($arenas)); }