Exemplo n.º 1
0
 /**
  * Execute the console command.
  *
  * @return mixed
  */
 public function handle()
 {
     $eventsIn3Days = $this->event->getEventsWithin3Days();
     foreach ($eventsIn3Days as $event) {
         $time = $this->getEventTime($event->time);
         $this->info('Event: ' . $event['name'] . ' at ' . $time->format('jS \\o\\f M \\a\\t h:ia'));
         $content = $event['name'] . ' at ' . $time->format('jS \\o\\f M \\a\\t h:ia') . ' #memtech ' . $event['event_url'];
         $tweet = $this->reformatStatus($content, $event, $time->format('jS \\o\\f M \\a\\t h:ia'));
         $tweet_at = $time->subDays(3)->subHours(10)->setTimezone('America/Chicago');
         // check if we already have a pending tweet
         $existing = Tweet::where('event_id', $event['event_id'])->where('days_before', 3)->first();
         if (is_null($existing)) {
             $this->tweet->create(['content' => $tweet, 'tweet_at' => $tweet_at, 'sent' => false, 'event_id' => $event['event_id'], 'days_before' => 3]);
         }
     }
     $eventsIn24hours = $this->event->getEventsWithin24Hours();
     foreach ($eventsIn24hours as $event) {
         $time = $this->getEventTime($event->time);
         $this->info('Event: ' . $event['name'] . ' at ' . $time->format('jS \\o\\f M \\a\\t h:ia'));
         $content = $event['name'] . ' at ' . $time->format('jS \\o\\f M \\a\\t h:ia') . ' #memtech ' . $event['event_url'];
         $tweet = $this->reformatStatus($content, $event, $time->format('jS \\o\\f M \\a\\t h:ia'));
         $tweet_at = $time->subHours(10)->setTimezone('America/Chicago');
         // check if we already have a pending tweet
         $existing = Tweet::where('event_id', $event['event_id'])->where('days_before', 0)->first();
         if (is_null($existing)) {
             $this->tweet->create(['content' => $tweet, 'tweet_at' => $tweet_at, 'sent' => false, 'event_id' => $event['event_id'], 'days_before' => 0]);
         }
     }
 }
Exemplo n.º 2
0
 public function setTweetAsSent($id)
 {
     $tweet = Tweet::find($id);
     $tweet->sent = true;
     if (!$this->option('debug')) {
         $tweet->save();
     }
     if ($this->option('debug')) {
         $this->info('We should have set tweet->id ' . $tweet->id . ' to sent');
     }
 }