function show(Pilot $pilot) { $active = Flight::with('departure', 'departure.country', 'arrival', 'arrival.country')->whereVatsimId($pilot->vatsim_id)->whereIn('state', array(0, 1, 3, 4))->first(); $flights = Flight::with('departure', 'departure.country', 'arrival', 'arrival.country')->whereVatsimId($pilot->vatsim_id)->whereState(2)->orderBy('arrival_time', 'desc')->take(15)->get(); $flightCount = Flight::whereVatsimId($pilot->vatsim_id)->whereState(2)->count(); $stats = new FlightStat(Flight::whereVatsimId($pilot->vatsim_id)); if ($pilot->processing == 0) { Queue::push('LegacyUpdate', $pilot->vatsim_id, 'legacy'); $pilot->processing = 2; $pilot->save(); } if ($pilot->processing == 2) { Messages::success('The data for this pilot is currently being processed. In a couple of minutes, all statistics will be available.')->one(); } $distances = $stats->distances($pilot->distance); $citypair = $stats->citypair(); if ($flights->count() > 0) { $durations = $stats->durations($pilot->duration); extract($durations); } // Charts: popular airlines, airports and aircraft $airlines = $stats->topAirlines(); $airports = $stats->topAirports(); $aircraft = $stats->topAircraft(); $this->javascript('assets/javascript/jquery.flot.min.js'); $this->javascript('assets/javascript/jquery.flot.pie.min.js'); $this->autoRender(compact('pilot', 'flights', 'active', 'distances', 'airlines', 'aircraft', 'airports', 'longest', 'shortest', 'citypair', 'hours', 'minutes'), $pilot->name); }
public function index() { $users = Cache::get('vatsim.users'); $year = Cache::get('vatsim.year'); $month = Cache::get('vatsim.month'); $day = Cache::get('vatsim.day'); $change = Cache::get('vatsim.change'); $changeArrow = Cache::get('vatsim.changeDirection'); $distance = Cache::get('vatsim.distance'); $flights = Flight::with('pilot', 'departure', 'arrival')->whereState(1)->whereMissing(0)->orderBy(DB::raw('RAND()'))->take(15)->get(); $this->autoRender(compact('users', 'year', 'month', 'day', 'change', 'changeArrow', 'distance', 'flights')); }
function index() { $flights = Flight::with('departureCountry', 'arrivalCountry', 'departure', 'arrival', 'pilot')->where('departure_time', '!=', '')->whereState(1)->orderBy('departure_time', 'desc')->orderBy('callsign')->paginate(25); $this->autoRender(compact('flights'), 'Flights'); }
function index() { $pilots = Flight::with('pilot')->select(DB::raw('vatsim_id, COUNT(vatsim_id) AS aggregate, SUM(distance) as distance, SUM(duration) as duration'))->orderBy('aggregate', 'desc')->groupBy('vatsim_id')->paginate(50); $this->autoRender(compact('pilots'), 'Pilots'); }
}); Route::get('search', ['as' => 'search', 'uses' => 'SearchController@index']); Route::get('citypair/{departure}-{arrival}', ['as' => 'citypair', 'uses' => 'FlightController@citypair'])->where('departure', '[A-Z0-9]{3,4}')->where('arrival', '[A-Z0-9]{3,4}'); /* |-------------------------------------------------------------------------- | Bindings |-------------------------------------------------------------------------- | | Bindings replace the variables in the URL with their respective classes | that are passed as a parameter to the controller methods. | */ Route::bind('flight', function ($value) { $flight = Flight::with(['aircraft', 'departure', 'arrival', 'pilot', 'departureCountry', 'arrivalCountry', 'airline', 'positions' => function ($positions) { $positions->join('updates', 'positions.update_id', '=', 'updates.id'); $positions->select('positions.*', DB::raw('updates.timestamp AS time')); $positions->orderBy('time', 'asc'); }])->find($value); if (is_null($flight) || $value == 0) { return App::abort(404); } else { return $flight; } }); Route::bind('atc', function ($value) { $atc = ATC::with('pilot')->find($value); if (is_null($atc) || $value == 0) { return App::abort(404); } else { return $atc; }