/**
  * GET (AJAX), /missions/{$slug}/telemetry. Fetches all mission telemetries for a specified mission,
  * ordered by the telemetry timestamp.
  *
  * @param $slug
  * @return \Illuminate\Http\JsonResponse
  */
 public function telemetry($slug)
 {
     $telemetryQuery = Telemetry::whereHas('mission', function ($q) use($slug) {
         $q->whereSlug($slug);
     })->orderBy('timestamp', 'ASC');
     if (Auth::isSubscriber()) {
         return response()->json($telemetryQuery->get());
     } else {
         return response()->json($telemetryQuery->get(['telemetry_id', 'timestamp', 'readout']));
     }
 }
 private function manageTelemetryRelations()
 {
     $currentTelemetry = $this->mission->telemetry->keyBy('telemetry_id');
     foreach ($this->input['mission']['telemetry'] as $telemetryInput) {
         // If the telemetry exists, update it, otherwise, create it
         if (array_key_exists('telemetry_id', $telemetryInput)) {
             $telemetry = $currentTelemetry->pull($telemetryInput['telemetry_id']);
             $telemetry->fill($telemetryInput);
             $telemetry->save();
         } else {
             $telemetry = new Telemetry($telemetryInput);
             $telemetry->mission()->associate($this->mission);
             $telemetry->save();
         }
     }
     // Delete any telemetry payloads
     if (!$currentTelemetry->isEmpty()) {
         Telemetry::whereIn('telemetry_id', $currentTelemetry->keys())->delete();
     }
 }
 public function CRS7()
 {
     Telemetry::create(['mission_id' => 24, 'timestamp' => 0, 'readout' => "We have liftoff of the Falcon 9"]);
     Telemetry::create(['mission_id' => 24, 'timestamp' => 0, 'readout' => "Falcon 9 has cleared the tower"]);
     Telemetry::create(['mission_id' => 24, 'timestamp' => 0, 'readout' => "Stage 1 propulsion is nominal"]);
     Telemetry::create(['mission_id' => 24, 'timestamp' => 0, 'readout' => "Vehicle's programming downrange"]);
     Telemetry::create(['mission_id' => 24, 'timestamp' => 0, 'readout' => "Stage 1 propellant utilization is active"]);
     Telemetry::create(['mission_id' => 24, 'timestamp' => 0, 'readout' => "Power and telemetry nominal"]);
     Telemetry::create(['mission_id' => 24, 'timestamp' => 0, 'readout' => "T+1 minute. Altitude [cutout], speed 290m/s, downrange distance 1.1km", 'speed' => 290, 'downrange' => 1100]);
     Telemetry::create(['mission_id' => 24, 'timestamp' => 0, 'readout' => "Vehicle's supersonic"]);
     Telemetry::create(['mission_id' => 24, 'timestamp' => 0, 'readout' => "Recovery droneship has AOS"]);
     Telemetry::create(['mission_id' => 24, 'timestamp' => 0, 'readout' => "Vehicle's reached maximum aerodynamic pressure"]);
     Telemetry::create(['mission_id' => 24, 'timestamp' => 0, 'readout' => "Stage 1 propulsion is still nominal"]);
     Telemetry::create(['mission_id' => 24, 'timestamp' => 0, 'readout' => "Power and telemetry remain nominal"]);
     Telemetry::create(['mission_id' => 24, 'timestamp' => 0, 'readout' => "MVac chill has begun"]);
     Telemetry::create(['mission_id' => 24, 'timestamp' => 0, 'readout' => "T+2 minutes. Altitude 32km, speed 1km/s, downrange distance 13km", 'altitude' => 32000, 'speed' => 1000, 'downrange' => 13000]);
     Telemetry::create(['mission_id' => 24, 'timestamp' => 0, 'readout' => "[Inaudible], this is the ROC, [inaudible]"]);
     Telemetry::create(['mission_id' => 24, 'timestamp' => 0, 'readout' => "ROC on the countdown net"]);
     Telemetry::create(['mission_id' => 24, 'timestamp' => 0, 'readout' => "Well, this is John Insprcker back at SpaceX broadcast headquarters in Hawthorne, we have lost the video from the vehicle, there was some type of anomaly during first stage flight, what we know is that the countdown was satisfactory, we did ignite the 9 Merlin engines, we successfully lifted off the Slick Forty launchpad at Cape Canaveral, we proceeded through the stressing events during flight, went through maximum aerodynamic pressure and went supersonic, however it appears something did occur during first stage operations. SpaceX engineers will be reviewing the data in order to learn more about what happened during the Falcon 9 flight. One of the unique features of Falcon 9 is the large amounts of data that come on separate telemetry streams from the first and the second stage. This will bring an end to the live webcast for today. Please check our website spacex.com, and our social media pages, where we will be providing you with more information as it becomes available. Thanks for joining us today."]);
 }