Ejemplo n.º 1
0
 /**
  * Execute the console command.
  *
  * @return mixed
  */
 public function handle()
 {
     $this->startLog();
     $dayOfWeek = Carbon::now()->addDays(self::PERIOD)->dayOfWeek;
     $trainingList = Training::where('day_of_week', $dayOfWeek)->where('status', Training::STATUS_ACITVE)->get();
     if ($trainingList->count() < 1) {
         $this->error('No games to remind');
         exit;
     }
     foreach ($trainingList as $training) {
         $msg = config('mls.chat_training_msg');
         $msg = str_replace('%training%', $training->name, $msg);
         $msg = str_replace('%time%', $training->getTime(), $msg);
         $msg = str_replace('%url%', route('training.visit', ['id' => $training->id]), $msg);
         $result = sendVkMsg($msg);
         $this->comment($result);
     }
     $this->endLog();
 }
Ejemplo n.º 2
0
 /**
  * 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();
 }