Beispiel #1
0
    public function getSinglePirep(Pirep $pirep)
    {
        // Do we have access to this PIREP?
        if ($pirep->booking->pilot->id !== PilotRepository::getCurrentPilot()->id) {
            return redirect('/pireps');
        }
        // Calculate some data bits (keep it out of the view)
        $extras = [];
        // Airborne Time
        $takeoff = new Carbon($pirep->departure_time);
        $landing = new Carbon($pirep->landing_time);
        $extras['airborneTime'] = $takeoff->diff($landing);
        // Blocks Time
        $offBlocks = new Carbon($pirep->off_blocks_time);
        $onBlocks = new Carbon($pirep->on_blocks_time);
        $extras['blocksTime'] = $offBlocks->diff($onBlocks);
        // Total Time
        $start = new Carbon($pirep->pirep_start_time);
        $finish = new Carbon($pirep->pirep_end_time);
        $extras['totalTime'] = $start->diff($finish);
        // Planned Route
        $routeService = new Route();
        $extras['routePoints'] = $routeService->getAllPointsForRoute($pirep->booking->route);
        // Format Text Log (ugly, I know!)
        $extras['log'] = str_replace('[', '
[', $pirep->log);
        // Display the PIREP!
        return view('pireps/single', ['pirep' => $pirep, 'extras' => $extras]);
    }
Beispiel #2
0
 public function getView(Pirep $pirep)
 {
     // Calculate some data bits (keep it out of the view)
     $extras = [];
     // Airborne Time
     $takeoff = new Carbon($pirep->departure_time);
     $landing = new Carbon($pirep->landing_time);
     $extras['airborneTime'] = $takeoff->diff($landing);
     // Blocks Time
     $offBlocks = new Carbon($pirep->off_blocks_time);
     $onBlocks = new Carbon($pirep->on_blocks_time);
     $extras['blocksTime'] = $offBlocks->diff($onBlocks);
     // Total Time
     $start = new Carbon($pirep->pirep_start_time);
     $finish = new Carbon($pirep->pirep_end_time);
     $extras['totalTime'] = $start->diff($finish);
     // Planned Route
     $routeService = new Route();
     $extras['routePoints'] = $routeService->getAllPointsForRoute($pirep->booking->route);
     // Format Text Log (ugly, I know!)
     $extras['log'] = str_replace('[', '
     [', $pirep->log);
     // Display the PIREP!
     return view('pireps/single', ['pirep' => $pirep, 'extras' => $extras, 'staffBar' => true]);
 }
Beispiel #3
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');
     }));
 }