当前位置: 首页>>代码示例>>PHP>>正文


PHP Flight::with方法代码示例

本文整理汇总了PHP中Flight::with方法的典型用法代码示例。如果您正苦于以下问题:PHP Flight::with方法的具体用法?PHP Flight::with怎么用?PHP Flight::with使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Flight的用法示例。


在下文中一共展示了Flight::with方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: show

 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);
 }
开发者ID:T-SummerStudent,项目名称:new,代码行数:28,代码来源:PilotController.php

示例2: index

 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'));
 }
开发者ID:T-SummerStudent,项目名称:new,代码行数:12,代码来源:HomeController.php

示例3: index

 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');
 }
开发者ID:T-SummerStudent,项目名称:new,代码行数:5,代码来源:FlightController.php

示例4: index

 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');
 }
开发者ID:T-SummerStudent,项目名称:new,代码行数:5,代码来源:ControllerController.php

示例5: function

});
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;
    }
开发者ID:T-SummerStudent,项目名称:new,代码行数:31,代码来源:routes.php


注:本文中的Flight::with方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。