public static function addVisit($game_id, $player_id, $visit = Stat::VISIT) { $stat = Stat::where('game_id', $game_id)->where('player_id', $player_id)->whereNotNull(Stat::VISIT)->first(); if ($stat) { $stat->{Stat::VISIT} = $visit; $stat->save(); } else { Stat::create(['game_id' => $game_id, 'player_id' => $player_id, Stat::VISIT => $visit]); } }
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]); }
private function saveGameStat(array $stat) { $validator = Validator::make($stat, StatRequest::getRules()); if (!$validator->fails()) { $statElem = Stat::where('game_id', $stat['game_id'])->where('player_id', $stat['player_id'])->whereNotNull($stat['parameter'])->first(); $data = ['game_id' => $stat['game_id'], 'player_id' => $stat['player_id'], $stat['parameter'] => $stat['value']]; if ($statElem) { $statElem->update($data); } else { Stat::create($data); } } }
public function store(StatRequest $request) { Stat::create(['game_id' => $request->get('game_id'), 'player_id' => $request->get('player_id'), $request->get('parameter') => $request->get('value')]); Flash::success(trans('general.created_msg')); return redirect(route('admin.stats')); }