/**
  * Create a new event instance.
  *
  * @param $isActive
  * @param null $videoId
  */
 public function __construct($videos)
 {
     foreach ($videos as $videoName => $videoId) {
         // Update the Redis parameters
         $spacexLivestream = json_decode(Redis::hget('live:streams', $videoName));
         if ($spacexLivestream === null) {
             $spacexLivestream = new \stdClass();
         }
         $spacexLivestream->isActive = true;
         $spacexLivestream->isAvailable = true;
         $spacexLivestream->youtubeVideoId = $videoId;
         Redis::hset('live:streams', $videoName, json_encode($spacexLivestream));
     }
     $this->videos = $videos;
 }
Ejemplo n.º 2
0
 /**
  * @return mixed
  */
 public function resumeCountdown()
 {
     // Parse launch date
     $newLaunchDate = Carbon::parse(Input::get('newLaunchDate'));
     // Update Redis
     Redis::hset('live:countdown', 'isPaused', false);
     Redis::hset('live:countdown', 'to', $newLaunchDate->toDateTimeString());
     // Event
     event(new LiveCountdownEvent(true, $newLaunchDate));
     // If it relates to a mission (and not a miscellaneous webcast)
     if (Redis::get('live:isForLaunch')) {
         $nextMission = Mission::future()->first();
         // Create a Prelaunch event
         PrelaunchEvent::create(['mission_id' => $nextMission->mission_id, 'event' => 'Launch Change', 'occurred_at' => Carbon::now(), 'scheduled_launch_exact' => $newLaunchDate]);
         // Update mission
         $nextMission->launch_paused = false;
         $nextMission->launch_date_time = $newLaunchDate;
         $nextMission->save();
     }
     return response()->json(null, 204);
 }
Ejemplo n.º 3
0
 private static function requestCache()
 {
     $cache_key = self::getCacheKey();
     $map = self::select('code', 'city_state')->orderBy('city_state', 'asc')->get();
     foreach ($map as $record) {
         $field = str_replace([',', ' '], ':', strtolower($record->city_state));
         $val = $record->code;
         Redis::hset($cache_key, $field, $val);
     }
 }