/** * Execute the console command. * * @return mixed */ public function handle() { $this->startLog(); $date = Carbon::now(); $gameList = Game::where('date', '>=', $date->format('Y-m-d 00:00:00'))->where('date', '<=', $date->addDays(self::PERIOD)->format('Y-m-d 23:59:59'))->where('reminder', Game::MSG_NOT_SENT)->get(); if ($gameList->count() < 1) { $this->error('No games to remind'); exit; } foreach ($gameList as $game) { $msg = $this->getMsg($game); $result = sendVkMsg($msg); if (preg_match('/"response":[0-9]+/', $result)) { $game->reminder = Game::MSG_SENT; $game->save(); $this->comment($result); $this->comment('Sent msg for game: ' . $game->id); } } $this->endLog(); }
public function setUserId($game_id, $user_id) { Game::where('$id', $game_id)->update(['user_id' => $user_id]); }
/** * Display a listing of the resource. * * @return Response */ public function index() { $user = User::getAuthUser(); $games = Game::where('team_id', Input::get('team_id'))->paginate(20); return response()->json($games, 200); }
public static function getSiblings(Game $game) { $siblings = []; $siblings['prev'] = Game::where('team_id', $game->team_id)->where('date', '<', $game->date)->orderBy('date', 'desc')->first(); $siblings['next'] = Game::where('team_id', $game->team_id)->where('date', '>', $game->date)->orderBy('date', 'asc')->first(); return $siblings; }
/** * Removes the specified Game. * * @param str $name * * @throws ModelNotFoundException * * @return bool */ public function removeGame($name) { return Game::where('name', $name)->firstOrFail()->delete(); }