本文整理汇总了PHP中Flight::whereVatsimId方法的典型用法代码示例。如果您正苦于以下问题:PHP Flight::whereVatsimId方法的具体用法?PHP Flight::whereVatsimId怎么用?PHP Flight::whereVatsimId使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Flight
的用法示例。
在下文中一共展示了Flight::whereVatsimId方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: flights
function flights(Pilot $pilot)
{
$flights = Flight::whereVatsimId($pilot->vatsim_id)->with('departureCountry', 'arrivalCountry', 'departure', 'arrival', 'pilot')->where('departure_time', '!=', '')->orderBy('startdate', 'desc')->orderBy('departure_time', 'desc')->orderBy('callsign')->paginate(50);
$this->autoRender(compact('flights', 'pilot'), 'Flights');
}
示例2: fire
function fire($job, $vatsim_id)
{
$pilot = Pilot::whereVatsimId($vatsim_id)->first();
if ($pilot->processing == 1) {
$job->delete();
return;
}
try {
$it = new XmlIterator\XmlIterator('https://cert.vatsim.net/vatsimnet/idstatusint.php?cid=' . $vatsim_id, 'user');
$official = iterator_to_array($it)[0];
$pilot->name = $official['name_first'] . ' ' . $official['name_last'];
$pilot->rating_id = $official['rating'];
} catch (ErrorException $e) {
}
$newFlights = array();
$flights = Flight::whereVatsimId($pilot->vatsim_id)->whereState(2)->get();
$totalDistance = 0;
$totalDuration = 0;
$totalFlights = $flights->count();
foreach ($flights as $flight) {
if ($flight->processed == 1) {
$totalDistance += $flight->distance;
$totalDuration += $flight->duration;
} else {
$callsign = str_replace('-', '', strtoupper($flight->callsign));
if (!is_null($airline = $this->getAirlines($callsign))) {
// Airline
$flight->isAirline($airline->icao);
unset($airline);
} elseif (!is_null($registration = $this->getRegistrations($callsign))) {
$flight->isPrivate($registration->country_id);
unset($registration);
}
if (!is_null($flight->departure_time) && !is_null($flight->arrival_time)) {
$duration = $this->duration($flight->departure_time, $flight->arrival_time);
$flight->duration = $duration;
$totalDuration += $duration;
unset($duration);
}
$distance = 0;
foreach ($flight->positions as $key => $position) {
if ($key > 0) {
$distance += $this->distance($position->lat, $position->lon, $previous->lat, $previous->lon);
}
$previous = $position;
}
$flight->distance = $distance;
// $flight->processed = true;
// $flight->save();
if (!is_nan($distance)) {
$totalDistance += $distance;
}
unset($distance, $previous);
}
$newFlights[] = array('id' => $flight->id, 'duration' => $flight->duration, 'distance' => $flight->distance, 'airline_id' => $flight->airline_id, 'callsign_type' => $flight->callsign_type);
unset($flight);
}
unset($flights);
Log::info('queue:legacy[' . $job->getJobId() . '] - processed flights');
DB::statement("create temporary table if not exists flights_temp (\n\t\t\t`id` int(10) unsigned NOT NULL,\n\t\t\t`callsign_type` tinyint(1) NOT NULL DEFAULT '0',\n\t\t\t`airline_id` varchar(10) COLLATE utf8_unicode_ci DEFAULT NULL,\n\t\t\t`duration` smallint(6) NOT NULL DEFAULT '0',\n\t\t\t`distance` smallint(6) NOT NULL DEFAULT '0',\n\t\t\tPRIMARY KEY (`id`)\n\t\t)");
Log::info('queue:legacy[' . $job->getJobId() . '] - created temp table flights');
$remaining = count($newFlights);
$step = 0;
do {
Log::info('queue:legacy[' . $job->getJobId() . '] - inserted flights - ' . $remaining);
DB::table('flights_temp')->insert(array_slice($newFlights, 100 * $step, 100));
$remaining -= 100;
$step++;
} while ($remaining > 0);
Log::info('queue:legacy[' . $job->getJobId() . '] - inserted flights - done');
DB::statement("update flights dest, flights_temp src set\n\t\t\tdest.callsign_type = src.callsign_type,\n\t\t\tdest.airline_id = src.airline_id,\n\t\t\tdest.duration = src.duration,\n\t\t\tdest.distance = src.distance,\n\t\t\tdest.processed = 1\n\t\twhere dest.id = src.id\n\t\t");
Log::info('queue:legacy[' . $job->getJobId() . '] - updated flights');
$atcs = ATC::whereVatsimId($vatsim_id)->whereNotNull('end')->get();
$totalDurationAtc = 0;
$totalAtc = $atcs->count();
$newAtc = array();
foreach ($atcs as $atc) {
if ($atc->processed) {
if ($atc->facility_id != 99) {
$totalDurationAtc += $atc->duration;
} else {
$totalAtc--;
}
} else {
$atc->facility_id = ends_with($atc->callsign, '_ATIS') ? 99 : $atc->facility_id;
$duration = $this->duration($atc->start, $atc->end);
$atc->duration = $duration;
if ($atc->facility_id != 99) {
$totalDurationAtc += $duration;
}
if ($atc->facility_id < 6) {
$airport = Airport::select('icao')->whereIcao(explode('_', $atc->callsign)[0])->orWhere('iata', '=', explode('_', $atc->callsign)[0])->pluck('icao');
$atc->airport_id = is_null($airport) ? null : $airport;
unset($airport);
} elseif ($atc->facility_id == 6) {
$sector = SectorAlias::select('sectors.code')->where('sector_aliases.code', '=', explode('_', $atc->callsign)[0])->join('sectors', 'sector_aliases.sector_id', '=', 'sectors.id')->pluck('code');
$atc->sector_id = is_null($sector) ? null : $sector;
unset($sector);
} else {
$totalAtc--;
//.........这里部分代码省略.........
示例3: array
if (!Input::has('from') || !Input::has('to')) {
return App::abort(404);
}
return Redirect::route('citypair', array('departure' => strtoupper(Input::get('from')), 'arrival' => strtoupper(Input::get('to'))), 301);
});
Route::get('routes.cfm', function () {
if (!Input::has('from') || !Input::has('to')) {
return App::abort(404);
}
return Redirect::route('citypair', array('departure' => strtoupper(Input::get('from')), 'arrival' => strtoupper(Input::get('to'))), 301);
});
Route::get('pilotredir.cfm', function () {
if (!Input::has('cid')) {
return Redirect::route('pilot.index');
}
$latestFlight = Flight::whereVatsimId(Input::get('cid'))->orderBy('id', 'desc')->first();
// Redirect to pilot page is last flight cannot be found
if (is_null($latestFlight)) {
return Redirect::route('pilot.show', array('pilot' => Input::get('cid')));
}
// Redirect to flight page when flight is found
return Redirect::route('flight.show', array('flight' => $latestFlight->id));
});
/*
|--------------------------------------------------------------------------
| Push Queue Handler
|--------------------------------------------------------------------------
|
| The route that received the jobs from the push queue should be here.
|
*/