コード例 #1
0
 /**
  * Creating a flight from user input.
  * Create a new booking and push $customer->id
  * and flight->id in.
  *
  * @param $request [request user input]
  * @param $id      [getting customer id]
  */
 public function addBookingDetail($request, $id)
 {
     $givenInput = $request->all();
     $data = $this->model->create($givenInput);
     $customer = $this->customer->getById($id);
     return Booking::create(['customer_id' => $customer->id, 'flight_id' => $data->id]);
 }
コード例 #2
0
 /**
  * Store a newly created resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @return \Illuminate\Http\Response
  */
 public function store(Requests\FlightStoreRequest $request, $slug)
 {
     $flight = new Flight();
     $flight->flight_thread_id = $request->flight_thread_id;
     $flight->aircraft_id = $request->aircraft_id;
     $flight->user_id = Auth::User()->id;
     $flight->departure_time = Carbon::createFromFormat('d.m.Y G:i', $request->departure_day . ' ' . $request->departure_time);
     $flight->arrival_time = Carbon::createFromFormat('d.m.Y G:i', $request->departure_day . ' ' . $request->departure_time)->addHours(24)->second(0);
     if ($flight->save()) {
         return response()->json('true');
     }
     return response()->json('false');
 }
コード例 #3
0
 public function slugs()
 {
     $slugs = Slug::orderBy('updated_at', 'desc')->get();
     /******************/
     $dirtyCities = Flight::doesntHave('city')->orderBy('country_code')->groupBy('city')->get();
     $cleanCities = City::groupBy('city_slug')->get();
     $noMatches = array();
     $dirtyCountries = array();
     $cleanCountries = array();
     foreach ($dirtyCities as $dirtyCity) {
         $similarsArray = array();
         foreach ($cleanCities as $cleanCity) {
             similar_text($dirtyCity->city_slug, $cleanCity->city_slug, $percent);
             $similarityArray[$cleanCity->city_slug] = $percent;
             $cleanCountries[$cleanCity->city_slug] = $cleanCity->country_code;
         }
         //sort in descending order
         arsort($similarityArray);
         //take first few with highest similarity
         $similarityArray = array_slice($similarityArray, 0, 8);
         $noMatches[$dirtyCity->city_slug] = $similarityArray;
         $dirtyCountries[$dirtyCity->city_slug] = $dirtyCity->country_code;
     }
     return view('scrapers.slugs')->with(['slugs' => $slugs, 'noMatches' => $noMatches, 'dirtyCountries' => $dirtyCountries, 'cleanCountries' => $cleanCountries]);
 }
コード例 #4
0
ファイル: PagesController.php プロジェクト: Alcondez/planes
 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());
 }
コード例 #5
0
 public function testAggregatesMatching()
 {
     $flight = $this->createBasicFlight(1000);
     $flightTwo = $this->createBasicFlight(1000);
     $conf = $this->createUserConferenceEntry($flight->id);
     $confTwo = $this->createUserConferenceEntry($flightTwo->id);
     $this->runAggregator($confTwo->id);
     $conf = UserConference::find($conf->id);
     $this->assertEquals($flightTwo->id, $conf->flight->id, "Flight not remapped");
     $this->assertNull(Flight::find($flight->id), "Flight not deleted");
 }
コード例 #6
0
 /**
  * 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();
         }
     });
 }
コード例 #7
0
 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]);
         }
     }
 }
コード例 #8
0
ファイル: FlightsSeeder.php プロジェクト: Alcondez/planes
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     DB::table('flights')->delete();
     $cities = Config::get('cities');
     $cities2 = Config::get('cities');
     //$cities = json_decode($citiesData, true);
     //$cities2 = json_decode($citiesData2, true);
     shuffle($cities2);
     $i = 0;
     foreach ($cities as $city) {
         $date = Carbon::create(2016, 1, 1, 0, 0, 0);
         Flight::create(array('departure' => $city['name'], 'destination' => $cities2[$i]['name'], 'departure_date' => $date->addWeeks(rand(1, 52))->format('Y-m-d'), 'first_class' => $this->random(200.0, 500.0), 'second_class' => $this->random(50.0, 200.0)));
         if (++$i > 500) {
             break;
         }
     }
 }
コード例 #9
0
 /**
  * Display a listing of the resource.
  *
  * @return \Illuminate\Http\Response
  */
 public function getIndex()
 {
     //
     $flights = Flight::all();
     return view('flight.index', ['flights' => $flights]);
 }
コード例 #10
0
 public function departures()
 {
     $departures = Flight::with('country')->where('scheduled_time', '>', Carbon::now()->subHours(12))->where('codeshare', 0)->where('departure', 1)->orderBy('scheduled_time', 'desc')->get();
     return $departures;
 }
コード例 #11
0
 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);
         }
     });
 }
コード例 #12
0
 public function flight($flight)
 {
     $this_arrival_flight = Flight::with('country')->where('flight_number', $flight)->where('arrival', 1)->first();
     $this_departure_flight = Flight::with('country')->where('flight_number', $flight)->where('departure', 1)->first();
     return view('pages.flight')->with(['this_arrival_flight' => $this_arrival_flight, 'this_departure_flight' => $this_departure_flight]);
 }
コード例 #13
0
ファイル: router.php プロジェクト: ray0be/fastdoc
F::route('GET /edit-nav/remove-category/@cat:[A-Za-z0-9_-]+', function ($cat) {
    Fastdoc::run('Admin\\EditNav', 'remove_category', array($cat));
});
// ######################################## \\
// ## ## ## ## // == page == \\ ## ## ## ## \\
F::route('POST /create/page', function () {
    Fastdoc::run('Admin\\EditNav', 'create_page');
});
F::route('GET /edit-nav/remove-page/@cat:[A-Za-z0-9_-]+/@page:[A-Za-z0-9_-]+', function ($cat, $page) {
    Fastdoc::run('Admin\\EditNav', 'remove_page', array($cat, $page));
});
/**
 * ===============================================
 *  Page view & Page edit
 * ===============================================
 */
F::route('/@cat:[A-Za-z0-9_-]*(/@page:[A-Za-z0-9_-]+)(\\.@mode:edit)', function ($cat, $page, $mode) {
    Fastdoc::savePageInfos(array('cat' => $cat, 'page' => $page));
    $mode = empty($mode) ? 'view' : 'edit';
    Fastdoc::run('Doc\\Doc', 'page', array($mode));
});
/**
 * ===============================================
 *  Public
 * ===============================================
 */
// ####################################### \\
// ## ## ## ## // == 404 == \\ ## ## ## ## \\
F::map('notFound', function () {
    Fastdoc::run('Core\\Core', 'error404');
});
コード例 #14
0
 public function transportSummary($confId, Request $req)
 {
     if (!Entrust::can(PermissionNames::ConferenceTransportationEdit($confId))) {
         return response()->json(['message' => 'cannot_manage_transport'], 403);
     }
     if (!$this->isValidConference($confId)) {
         return response()->json(['message' => 'conference_not_found'], 404);
     }
     $userConfs = UserConference::where('needsTransportation', '=', true)->where('conferenceID', $confId)->where('approved', 1)->with(array('user' => function ($q) {
         $q->select('id', 'firstName', 'lastName', 'accountID');
     }))->with('userTransportation');
     $transports = [];
     foreach ($userConfs->get() as &$userConf) {
         $ut = $userConf->userTransportation;
         if ($ut != null) {
             $transport = Transportation::where('id', $ut->transportationID)->first();
             $transports[$transport->id] = $transport;
         }
     }
     $flightsList = $userConfs->distinct()->lists('flightID');
     $flights = Flight::whereIn('id', $flightsList)->get()->keyBy('id')->toArray();
     $conference = Conference::where('id', $confId)->get()->toArray();
     $summary = $this->buildSummaryJson($conference, $flights, $userConfs->get()->toArray(), $transports);
     return response()->json($summary, 200);
 }
コード例 #15
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();
     }
 }
コード例 #16
0
ファイル: Fastdoc.php プロジェクト: ray0be/fastdoc
 /**
  * Save information about the page
  */
 public static function savePageInfos(array $params = array())
 {
     F::set('pageinfos', $params);
 }