Beispiel #1
0
 public static function todayStats()
 {
     $today = \Carbon\Carbon::today();
     $now = \Carbon\Carbon::now();
     $statistics = \App\Statcache::whereBetween('created_at', [$today, $now])->first();
     if (!$statistics) {
         $planets = Planet::all()->count();
         $bPlanets = \App\Bariplanet::all()->count();
         $regions = \App\Region::all()->count();
         $addresses = \App\Address::all()->count();
         $tf = Planet::where('planet', '<', 4)->count();
         $bTf = \App\Bariplanet::where('planet', '<', 4)->count();
         $statistics = \App\Statcache::create(['planets' => $planets + $bPlanets, 'regions' => $regions, 'tf' => $tf + $bTf, 'addresses' => $addresses, 'latest_stars' => 0, 'latest_planets' => 0, 'latest_regions' => 0, 'latest_addresses' => 0]);
     }
     $stat['latest'] = $statistics->latest_stars + $statistics->latest_planets;
     $stat['total'] = $statistics->planets;
     $stat['sys'] = $statistics->addresses;
     $stat['tf'] = $statistics->tf;
     $stat['reg'] = $statistics->regions;
     return $stat;
 }
Beispiel #2
0
 protected function saveStats()
 {
     $today = \Carbon\Carbon::today();
     $now = \Carbon\Carbon::now();
     $this->statistics = \App\Statcache::whereBetween('created_at', [$today, $now])->first();
 }