/** * Display a listing of the resource. * * @return Response */ public function index() { $months = Month::lists('name', 'id')->toArray(); $runningGameweeks = Gameweek::incomplete()->get()->filter(function ($gw) { return $gw->started(); }); $runningGameweeks->each(function ($gw, $key) { $gw->overFixtureCnt = $gw->fixtures()->over()->get()->count(); $gw->pendingFixtureCnt = $gw->fixtures()->get()->filter(function ($fxt) { return $fxt->isClosed() and !$fxt->isOver(); })->count(); }); $upcomingGameweeks = Gameweek::incomplete()->get()->filter(function ($gw) { return !$gw->started(); }); $completeGameweeks = Gameweek::complete()->get(); return view('admin.gameweek.index', compact('months', 'runningGameweeks', 'upcomingGameweeks', 'completeGameweeks')); }