public function index()
 {
     $usersData = [];
     $usersData['count'] = User::all()->count();
     $usersData['incompleteCount'] = User::where('status', 0)->count();
     $picsData = [];
     $picsData['count'] = Pic::all()->count();
     $clubsData = [];
     $clubsData['count'] = Club::all()->count();
     $badgesData = [];
     $badgesData['count'] = Badge::all()->count();
     $fixtures = Fixture::all();
     $fixturesData = [];
     $fixturesData['count'] = $fixtures->count();
     $fixturesData['overCount'] = $fixtures->filter(function ($fxt) {
         return $fxt->isOver();
     })->count();
     $fixturesData['closedNotOverCount'] = $fixtures->filter(function ($fxt) {
         return $fxt->isClosed() and !$fxt->isOver();
     })->count();
     $gameweeks = Gameweek::all();
     $gameweeksData = [];
     $gameweeksData['count'] = $gameweeks->count();
     $gameweeksData['completeCount'] = Gameweek::complete()->get()->count();
     $gameweeksData['pendingCount'] = Gameweek::incomplete()->get()->filter(function ($gw) {
         return $gw->hasCompletedFixture();
     })->count();
     $adminsData = [];
     $adminsData['count'] = Admin::all()->count();
     return view('admin.dashboard.index', compact('usersData', 'picsData', 'clubsData', 'badgesData', 'fixturesData', 'gameweeksData', 'adminsData'));
 }
 /**
  * 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'));
 }
Пример #3
0
 /**
  * Show the application home (predict) page to the user
  * 
  * @return Response
  */
 public function index()
 {
     $user = \Auth::user();
     $gws = \App\Gameweek::incomplete()->take(2)->with('fixtures')->with(['fixtures.predictions' => function ($query) use($user) {
         $query->where('user_id', $user->id);
     }])->get();
     foreach ($gws as $gw) {
         $userGameweek = $user->gameweeks()->where('gameweek_id', $gw->id)->first();
         $boostId = null;
         $boostedClosed = false;
         if ($userGameweek) {
             $boostId = $userGameweek->pivot->boost_id;
             if ($boostId) {
                 $boostedClosed = \App\Fixture::find($boostId)->isClosed();
             }
         }
         $gw->boostId = $boostId;
         $gw->boostedClosed = $boostedClosed;
     }
     $nameOfPage = 'home';
     return view('pages.home', compact('gws', 'user', 'nameOfPage'));
 }