public function actionView($id) { $statModel = Stat::findOne(['b_id' => $id]); if (!$statModel) { $statModel = new Stat(); } $statModel->b_id = $id; $statModel->views += 1; $statModel->save(); die('view recorded for: ' . $id); }
public function record() { $phraseId = $this->json('phrase_id'); $userId = $this->json('user_id'); $username = $this->json('username'); $milliseconds = $this->json('milliseconds', 0); $wpm = $this->json('wpm', 0); $nwpm = $this->json('nwpm', 0); $errors = $this->json('errors', 0); $color = $this->json('color', 'black'); $isMobile = $this->json('isMobile', false); $isTablet = $this->json('isTablet', false); $isDNQ = $this->json('isDNQ', false); if (!$userId) { // Generate UserId: $username = User::generateUsername(); $userId = User::createNew(['username' => $username]); } else { // Update Username User::update($userId, ['username' => $username]); } $statId = Stat::createNew(['phrase_id' => $phraseId, 'user_id' => $userId, 'milliseconds' => $milliseconds, 'wpm' => $wpm, 'nwpm' => $nwpm, 'errors' => $errors, 'color' => $color, 'isMobile' => $isMobile, 'isTablet' => $isTablet, 'isDNQ' => $isDNQ]); $stats = Stat::findById($statId); $transform = Stat::transform($stats, ['username' => $username]); return $this->success($transform); }
public function view(Game $game) { $team = Team::find(config('mls.team_id')); $statList = StatRepository::getStatsByGameId($game->id); $playerList = PlayerRepository::getListByTeamId($game->team_id); $statGroupList = Stat::getParameterKeys(); return view('frontend.game.view')->with('game', $game)->with('statList', $statList)->with('playerList', $playerList->lists('name', 'id'))->with('team', $team)->with('statGroupList', $statGroupList); }
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; } }
public function destroy(Stat $stat) { $stat->delete(); Flash::success(trans('general.delete_msg')); return redirect(route('admin.stats')); }
public function getRanks() { $ranked = StatFinal::where('character_id', $this->id)->with('stat')->orderBy('rank', 'asc')->get(); $unranked = Stat::whereNotIn('id', $ranked->lists('stat_id'))->get(); return ['ranked' => $ranked, 'unranked' => $unranked]; }
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; }
/** * Save the result to the database, or update any existing data. * * @return void */ protected function saveResult($result = null) { if (!is_null($result) && is_numeric($result)) { $start = $this->period->start; $end = $this->period->end; $stat = Stat::firstOrNew(['start' => $start, 'name' => $this->getStatName(), 'period' => $this->getPeriodName()]); $stat->value = $result; $stat->save(); } }