public function getEdit($username) { $user = User::where('username', $username)->with(['notifications.notificationType', 'profile'])->firstOrFail(); $notificationTypes = NotificationType::toArray(); $userNotifications = $user->notifications->keyBy('notification_type_id'); $hasNotifications = []; foreach ($notificationTypes as $notificationKey => $notificationValue) { $hasNotifications[$notificationKey] = $userNotifications->has($notificationValue); } JavaScript::put(['missions' => Mission::with('featuredImage')->get(['mission_id', 'name']), 'patches' => Mission::whereNotNull('mission_patch')->with('missionPatch')->get(['mission_id', 'name']), 'notifications' => $hasNotifications, 'user' => $user]); return view('users.edit', ['user' => $user]); }
public function aboutNextLaunch() { return response()->json(['nextLaunch' => Mission::with(['vehicle'])->future()->first()]); }
public function update() { $this->mission = Mission::with('payloads', 'partFlights.part', 'spacecraftFlight.astronautFlights.astronaut', 'telemetry')->find($this->input('mission')['mission_id']); DB::beginTransaction(); try { // Fill mission $this->mission->fill($this->input('mission')); $this->mission->save(); //$this->mission->push(); // Update any relations, create new relations, delete any relations which have been removed. $this->managePayloadRelations(); $this->managePartFlightRelations(); $this->manageSpacecraftFlightRelation(); $this->manageTelemetryRelations(); DB::commit(); } catch (Exception $e) { DB::rollback(); } return $this->mission; }
/** * Execute the console command. * * @return mixed */ public function handle() { // Mass assignment in Laravel doesn't set timestamps, manually create them instead $now = Carbon::now(); // Fetch all the missions we want to query orbital elements for. $missions = Mission::with(['orbitalElements', 'partFlights'])->whereComplete()->where('outcome', MissionOutcome::Success)->whereHas('upperStage', function ($q) { $q->whereNotNull('upperstage_norad_id'); })->get(); // Login to SpaceTrack $ephemeris = new Ephemeris(Config::get('services.spacetrack.identity'), Config::get('services.spacetrack.password')); $allOrbitalElements = collect(); foreach ($missions as $mission) { // Create the identifier $identifier = new NoradID($mission->upperStage->upperstage_norad_id); if ($mission->orbitalElements->count() == 0) { // Attempt to fetch all TLE's as we presume the mission was just recently completed or added and we cannot // place a reasonable boundary on when to start fetching TLE's. $tles = collect($ephemeris->tles()->latest()->satellite($identifier)->fetch()); $this->info('Got ' . $tles->count() . ' tles for ' . $identifier->identify()); } else { // Only fetch TLE's from the past 30 days because we know this query runs every day (why not // fetch from the past day? SpaceTrack clarifies: "Note that in rare cases space-track may // receive a TLE with an earlier EPOCH than the most recently uploaded TLE.") $tles = $ephemeris->tles()->satellite($identifier)->lastMonth()->fetch(); $tles = collect($tles)->filter(function ($tle) use($mission) { return $this->isTLENew($tle, $mission->orbitalElements); }); } // Turn the TLE's into OrbitalElements $missionOrbitalElements = $tles->map(function ($tle) use($mission, $now) { $orbitalElement = new OrbitalElement(); $orbitalElement->part_flight_id = $mission->upperStage->part_flight_id; $orbitalElement->object_name = $tle->OBJECT_NAME; $orbitalElement->object_type = $tle->OBJECT_TYPE; $orbitalElement->classification_type = $tle->CLASSIFICATION_TYPE; $orbitalElement->epoch = $tle->EPOCH; $orbitalElement->mean_motion = $tle->MEAN_MOTION; $orbitalElement->eccentricity = $tle->ECCENTRICITY; $orbitalElement->inclination = $tle->INCLINATION; $orbitalElement->ra_of_asc_node = $tle->RA_OF_ASC_NODE; $orbitalElement->arg_of_pericenter = $tle->ARG_OF_PERICENTER; $orbitalElement->mean_anomaly = $tle->MEAN_ANOMALY; $orbitalElement->ephemeris_type = $tle->EPHEMERIS_TYPE; $orbitalElement->element_set_no = $tle->ELEMENT_SET_NO; $orbitalElement->rev_at_epoch = $tle->REV_AT_EPOCH; $orbitalElement->bstar = $tle->BSTAR; $orbitalElement->mean_motion_dot = $tle->MEAN_MOTION_DOT; $orbitalElement->mean_motion_ddot = $tle->MEAN_MOTION_DDOT; $orbitalElement->file = $tle->FILE; $orbitalElement->tle_line0 = $tle->TLE_LINE0; $orbitalElement->tle_line1 = $tle->TLE_LINE1; $orbitalElement->tle_line2 = $tle->TLE_LINE2; $orbitalElement->semimajor_axis = $tle->SEMIMAJOR_AXIS; $orbitalElement->period = $tle->PERIOD; $orbitalElement->apogee = $tle->APOGEE; $orbitalElement->perigee = $tle->PERIGEE; $orbitalElement->created_at = $orbitalElement->updated_at = $now; return $orbitalElement; }); $missionOrbitalElements->each(function ($orbitalElement) { OrbitalElement::create($orbitalElement->toArray()); }); } }
/** * @return \Illuminate\Http\JsonResponse */ public function all() { $allMissions = Mission::with('featuredImage')->get(); return response()->json($allMissions); }
public function show() { JavaScript::put(['tags' => Tag::all(), 'missions' => Mission::with('featuredImage')->get(), 'publishers' => Publisher::all()]); return view('missionControl.create', ['recentUploads' => Object::inMissionControl()->orderBy('created_at', 'desc')->take(10)->get()]); }