コード例 #1
0
 public function city($country, $city)
 {
     $this_city = City::with('country')->where('city_slug', $city)->first();
     $airlines = Flight::where('city_slug', $city)->where('scheduled_time', '>', Carbon::now()->subMonths(1))->where('codeshare', 0)->orderBy('airline', 'asc')->groupBy('airline')->get();
     /*
     $arrivalflights = Arrival::where('scheduled_time','>',Carbon::now()->subMonths(1))
     	->where('origin_city', $city)
     	->where('codeshare',0)
     	->groupBy('flight_number')
     	->get();
     */
     $arrivalflights = Flight::select(DB::raw('*, strftime("%H:%M %w",scheduled_time) as timeDay, strftime("%H:%M",scheduled_time) as time, strftime("%w",scheduled_time) as dayofweek'))->where('scheduled_time', '>', Carbon::now()->subWeeks(1))->where('city_slug', $city)->where('codeshare', 0)->where('arrival', 1)->orderBy('dayofweek', 'asc')->orderBy('time', 'asc')->groupBy('timeDay')->get();
     $departureflights = Flight::select(DB::raw('*, strftime("%H:%M %w",scheduled_time) as timeDay, strftime("%H:%M",scheduled_time) as time, strftime("%w",scheduled_time) as dayofweek'))->where('scheduled_time', '>', Carbon::now()->subWeeks(1))->where('city_slug', $city)->where('codeshare', 0)->where('departure', 1)->orderBy('dayofweek', 'asc')->orderBy('time', 'asc')->groupBy('timeDay')->get();
     $arrivals = Flight::with('country')->where('city_slug', $city)->where('codeshare', 0)->where('arrival', 1)->orderBy('scheduled_time', 'desc')->take(5)->get();
     $departures = Flight::with('country')->where('city_slug', $city)->where('codeshare', 0)->where('departure', 1)->orderBy('scheduled_time', 'desc')->take(5)->get();
     return view('pages.city')->with(['this_city' => $this_city, 'airlines' => $airlines, 'arrivalflights' => $arrivalflights, 'departureflights' => $departureflights, 'arrivals' => $arrivals, 'departures' => $departures]);
 }
コード例 #2
0
 public function BulkUpdate($hour_stamp)
 {
     //arrivals to update
     $flights = Flight::select(DB::raw('*, min("id"), scheduled_time || city AS plane'))->where('hour_stamp', $hour_stamp)->orderBy('scheduled_time', 'desc')->groupBy('plane')->get();
     foreach ($flights as $flight) {
         $flight->codeshare = 0;
         $flight->save();
     }
 }