public function searchFlights(Request $request) { $pass_amt = $request->input('pass_amt'); $flights = Flight::where('departure', $request->input('departure'))->where('destination', $request->input('arrival'))->where('departure_date', $request->input('date_from'))->get(); $from = $request->input('departure'); $to = $request->input('arrival'); return view('pages.flights', compact('flights', 'to', 'from', 'pass_amt')); //return dd($request->all()); }
/** * Execute the job. * * @return void */ public function handle() { DB::transaction(function () { $registration = UserConference::find($this->registrationId); $currentFlight = $registration->flight; if (!isset($currentFlight)) { return; } $others = Flight::where('flightNumber', $currentFlight->flightNumber)->where('airline', $currentFlight->airline)->where('arrivalDate', $currentFlight->arrivalDate)->where('arrivalTime', $currentFlight->arrivalTime)->where('airport', $currentFlight->airport)->where('id', '<>', $currentFlight->id)->get(); foreach ($others as $otherFlight) { UserConference::where('flightID', $otherFlight->id)->update(['flightID' => $currentFlight->id]); $otherFlight->delete(); } }); }
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]); }
public function FillFromArrivals() { //set all to false DB::table('cities')->update(array('prague_operated' => 0)); //set all since last month true $recentFlights = Flight::where('scheduled_time', '>', Carbon::now()->subMonths(1))->groupBy('city')->get(); foreach ($recentFlights as $flight) { $raw_input = $flight->city . '+' . $flight->country_code; $address = Address::has('city')->where('raw_input', $raw_input)->first(); if (!empty($address)) { $address->city->prague_operated = 1; $address->push(); } else { Address::firstOrCreate(['raw_input' => $raw_input]); } } }
private function processRegistration($req, $conferenceID, $accountID) { return DB::transaction(function () use($req, $conferenceID, $accountID) { //Grab request data for use later $needsTransport = $req['needsTransportation']; $needsAccommodation = $req['needsAccommodation']; $attendees = $req['attendees']; //Check whether dependents are okay/owned by the current user if (!CheckDependents::dependentsOkay($attendees)) { return ["message" => "bad_attendee_listing", "code" => 400, "attendees" => $attendees]; } $existing = UserConference::where('conferenceID', $conferenceID)->whereIn('userID', $attendees)->count(); if ($existing > 0) { return ["message" => "already_registered", "code" => 400, "attendees" => $attendees]; } //If the request explicitly doesn't have a flight, just register attendees without one if (isset($req['hasFlight'])) { Log::debug("Attendees being registered without a flight."); if (!$req['hasFlight']) { return $this->registerAttendees($conferenceID, $attendees, $needsTransport, $needsAccommodation, null); } } $number = $req['flight']['number']; $arrivalDay = $req['flight']['arrivalDate']; $arrivalTime = $req['flight']['arrivalTime']; $airline = $req['flight']['airline']; $airport = $req['flight']['airport']; //Grab (checked) matching flights for airline/flight number/date $flights = Flight::where('flightNumber', $number)->where('airline', $airline)->where('arrivalDate', $arrivalDay)->where('isChecked', true)->get(); if (sizeof($flights) >= 1) { foreach ($flights as $row) { if ($row->arrivalTime == $arrivalTime && $row->airport == $airport) { Log::info("Attendees using {$row->airline} flight {$row->flightNumber} being registered using existing flight"); return $this->registerAttendees($conferenceID, $attendees, $needsTransport, $needsAccommodation, $row->id); } } return ["message" => "flight_data_mismatch", "code" => 400, "attendees" => $attendees]; } else { //Create a new flight with the given data $flight = new Flight(); $flight->flightNumber = $number; $flight->airline = $airline; $flight->arrivalDate = $arrivalDay; $flight->arrivalTime = $arrivalTime; $flight->airport = $airport; $flight->isChecked = false; $flight->save(); Log::info("Attendees using {$flight->airline} flight {$flight->flightNumber} being registered using new flight"); return $this->registerAttendees($conferenceID, $attendees, $needsTransport, $needsAccommodation, $flight->id); } }); }