public function index() { $stat = Stat::where('place', Input::get('place'))->first(); if ($stat) { $stat->count++; $stat->save(); } else { Stat::create(['place' => Input::get('place'), 'url' => Input::get('url'), 'count' => 1]); } $url = Input::get('url'); return view('stat', ['url' => $url]); }
public function get($name, $period, $start = null, $end = null) { $now = Carbon::now(); $start = $start ? $this->createDate($start) : $now->copy()->subWeek(); $end = $end ? $this->createDate($end) : $now->copy(); if ($period == 'all_time') { $start = null; $end = null; } $stats = Stat::where('name', '=', $name)->where('period', '=', $period); if ($start) { $stats = $stats->where('start', '>=', $start); } if ($end) { $stats = $stats->where('start', '<', $end); } $return = $stats->orderBy('start')->lists('value'); if ($period == 'all_time') { if (count($return) != 0) { return $return[0]; } else { return 0; } } else { return $return; } }
private static function removeVisits($id) { Stat::where('game_id', $id)->whereNotNull(Stat::VISIT)->delete(); }
public static function getStatsByGameId($game_id) { $stats[Stat::GOAL] = Stat::where('game_id', $game_id)->whereNotNull(Stat::GOAL)->get(); $stats[Stat::ASSIST] = Stat::where('game_id', $game_id)->whereNotNull(Stat::ASSIST)->get(); $stats[Stat::YELLOW_CARD] = Stat::where('game_id', $game_id)->whereNotNull(Stat::YELLOW_CARD)->get(); $stats[Stat::RED_CARD] = Stat::where('game_id', $game_id)->whereNotNull(Stat::RED_CARD)->get(); return $stats; }