Ejemplo n.º 1
0
 /**
  * Execute the console command.
  *
  * @return mixed
  */
 public function handle()
 {
     $events = GameEvent::where('start', '>=', Carbon::now('America/Chicago'))->orderBy('start', 'ASC')->get();
     $messenger = new Messages();
     if (count($events) > 0) {
         foreach ($events as $event) {
             $this->info('Checking event: ' . $event->title);
             $diff = $event->start->diffInSeconds(Carbon::now('America/Chicago'));
             $this->info('Event happens in ' . $diff . ' seconds.');
             if (!$event->alert_15) {
                 if ($diff <= $this->seconds_in_15minutes) {
                     $this->info('Alerting members of fireteam, that its 15 minutes before event');
                     foreach ($event->attendees as $attendee) {
                         $user = $attendee->user;
                         $messenger->sendMessage($user, '<strong>The Event: <i> (' . $event->getHumanType() . ') ' . $event->title . '</i></strong> starts in about 15 minutes.<br /><br /><i>You RSVP`d to this Event, which is why you are being alerted</i>.');
                     }
                     $event->alert_15 = true;
                     $event->save();
                 }
             }
             if (!$event->alert_5) {
                 if ($diff <= $this->seconds_in_5minutes) {
                     $this->info('Alerting members of fireteam, that its 5 minutes before event.');
                     foreach ($event->attendees as $attendee) {
                         $user = $attendee->user;
                         $messenger->sendMessage($user, '<strong>The Event: <i> (' . $event->getHumanType() . ') ' . $event->title . '</i></strong> starts in about 5 minutes.<br /><br /><i>You RSVP`d to this Event, which is why you are being alerted</i>.');
                     }
                     $event->alert_5 = true;
                     $event->save();
                 }
             }
         }
     }
 }
Ejemplo n.º 2
0
 public function postRsvpEvent(AddRSVP $request)
 {
     $game_id = $request->get('game_id');
     try {
         $event = GameEvent::where('id', intval($game_id))->firstOrFail();
         $attendee = new Attendee();
         $attendee->game_id = $event->id;
         $attendee->membershipId = $this->user->account->destiny_membershipId;
         $attendee->characterId = $request->get('character');
         $attendee->account_id = $this->user->account->id;
         $attendee->user_id = $this->user->id;
         $attendee->save();
         // hit bot
         if (app()->environment() == "production") {
             $messenger = new Messages();
             $messenger->sendGroupMessage('<strong>' . $this->user->account->gamertag . '</strong> confirmed RSVP to event: <strong>' . $event->title . '</strong>');
         }
         return \Redirect::action('CalendarController@getEvent', [$event->id])->with('flash_message', ['type' => 'success', 'header' => 'RSVP Confirmed!']);
     } catch (ModelNotFoundException $e) {
         return false;
     }
 }