示例#1
0
 public function getDoJumpseat(Route $route)
 {
     // todo: VALIDATE!
     $pilot = PilotRepository::getCurrentPilot();
     // Save this jumpseat so we can track them!
     $booking = new Booking();
     $booking->pilot()->associate($pilot);
     $booking->route()->associate($route);
     $booking->aircraft_id = null;
     // This indicates a jumpseat booking
     $booking->callsign = 'JUMPSEAT';
     // This also indicates a jumpseat booking
     $booking->save();
     $booking->delete();
     // Put in a dummy PIREP
     $pirep = new Pirep();
     $pirep->booking()->associate($booking);
     $pirep->pirep_data = ['jumpseat' => true];
     $pirep->status = 'complete';
     $pirep->points = 0;
     $pirep->landing_rate = 0;
     $pirep->fuel_used = 0;
     $pirep->load = 0;
     $pirep->save();
     $pilot->location()->associate($route->arrivalAirport);
     $pilot->save();
     return redirect('/flights');
 }
示例#2
0
 /**
  * Bind data to the view.
  *
  * @param Route $route
  * @param  View $view
  */
 public function compose(View $view)
 {
     $routeService = new Route();
     $pilot = PilotRepository::getCurrentPilot();
     $currentBooking = Booking::has('pirep', '<', 1)->where('pilot_id', '=', $pilot->id)->first();
     $view->with('currentBooking', $currentBooking);
     $view->with('upcomingBookings', Booking::has('pirep', '<', 1)->limit(10)->skip(1)->where('pilot_id', '=', $pilot->id)->get());
     $view->with('routePoints', $routeService->getAllPointsForRoute($currentBooking->route));
     $view->with('depMetar', Cache::remember('Metar:' . $currentBooking->route->departureAirport->icao, 10, function () use($currentBooking) {
         return file_get_contents('http://weather.noaa.gov/pub/data/observations/metar/decoded/' . strtoupper($currentBooking->route->departureAirport->icao) . '.TXT');
     }));
     $view->with('arrMetar', Cache::remember('Metar:' . $currentBooking->route->arrivalAirport->icao, 10, function () use($currentBooking) {
         return file_get_contents('http://weather.noaa.gov/pub/data/observations/metar/decoded/' . strtoupper($currentBooking->route->arrivalAirport->icao) . '.TXT');
     }));
 }
示例#3
0
 /**
  * Bind data to the view.
  *
  * @param  View  $view
  * @return void
  */
 public function compose(View $view)
 {
     $pilot = PilotRepository::getCurrentPilot();
     $currentLocation = $pilot->location;
     $lastBooking = Booking::has('pirep', '<', 1)->where('pilot_id', '=', $pilot->id)->orderBy('created_at', 'desc')->first();
     if (count($lastBooking) == 1) {
         $currentLocation = $lastBooking->route->arrivalAirport;
     }
     $view->with('currentLocation', $currentLocation);
     // Ordered flights list
     $sortedRoutes = [];
     $availableRoutes = RoutesRepository::getRoutesFrom($currentLocation);
     $view->with('availableRoutes', $availableRoutes);
     foreach ($availableRoutes as $route) {
         $sortedRoutes[$route->arrivalAirport->region->country->continent][$route->arrivalAirport->region->country->name][$route->arrivalAirport->region->name][] = (object) $route->arrivalAirport->toArray();
     }
     $view->with('sortedRoutes', $sortedRoutes);
 }
示例#4
0
 public static function countBookedFlights()
 {
     return count(Booking::has('pirep', '<', 1)->where('pilot_id', '=', self::getCurrentPilot()->id)->get()->toArray());
 }
示例#5
0
 private function handleSearchFlight($request)
 {
     $pilot = Pilot::find($request->input('dbid'));
     if ($request->has('departureicao')) {
         $availableRoutes = Route::whereHas('departureAirport', function ($q) use($request) {
             $q->where('icao', '=', $request->input('departureicao'));
         })->where('airline_id', '=', $pilot->airline->id)->get();
     } else {
         $currentLocation = $pilot->location;
         $lastBooking = Booking::where('pilot_id', '=', $pilot->id)->orderBy('created_at', 'desc')->first();
         if (count($lastBooking) == 1) {
             $currentLocation = $lastBooking->route->arrivalAirport;
         }
         $availableRoutes = Route::where('departure_id', '=', $currentLocation->id)->where('airline_id', '=', $pilot->airline->id)->get();
     }
     $routesList = [];
     foreach ($availableRoutes as $route) {
         if ($request->has('arrivalicao') && $route->arrivalAirport->icao != $request->input('arrivalicao')) {
             continue;
         }
         $routesList[] = ["routeid" => $route->id, "code" => '', "flightnumber" => 'FR1234', "departureicao" => $route->departureAirport->icao, "arrivalicao" => $route->arrivalAirport->icao, "route" => $route->route, "cruisingaltitude" => 38000, "aircraft" => 'TBA', "flighttime" => "Unknown", "departuretime" => 0, "arrivaltime" => 0, "daysofweek" => ''];
     }
     $return = '';
     $runcount = 0;
     foreach ($routesList as $singleRoute) {
         if ($runcount != 0) {
             $return .= ";";
         }
         $singleRoute = str_replace(";", "", $singleRoute);
         $singleRoute = str_replace(",", "", $singleRoute);
         $return .= $singleRoute['routeid'] . "|" . $singleRoute['code'] . "|" . $singleRoute['flightnumber'] . "|" . $singleRoute['departureicao'] . "|" . $singleRoute['arrivalicao'] . "|" . $singleRoute['route'] . "|" . $singleRoute['cruisingaltitude'] . "|" . $singleRoute['aircraft'] . "|" . $singleRoute['flighttime'] . "|" . $singleRoute['departuretime'] . "|" . $singleRoute['arrivaltime'] . "|" . $singleRoute['daysofweek'];
         $runcount++;
     }
     return $return;
 }