Esempio n. 1
0
 /**
  * Execute the console command.
  *
  * @return mixed
  */
 public function fire()
 {
     // Parse the CSV file and insert rows
     $this->info('Loading CSV...');
     $airportsFile = new File($this->argument('file'));
     $airportsFile = $airportsFile->openFile();
     $airportsFile->setFlags(SplFileObject::READ_CSV);
     $this->info('Beginning Import...');
     $i = 0;
     foreach ($airportsFile as $airport) {
         $i++;
         if ($i % 10 == 0) {
             $this->comment('Imported ' . $i . '...');
         }
         if (isset($airport[1]) && $i > 1) {
             $insertAirport = new Airport();
             $insertAirport->icao = $airport[1];
             $insertAirport->iata = $airport[13];
             $insertAirport->name = $airport[3];
             $insertAirport->latitude = $airport[4];
             $insertAirport->longitude = $airport[5];
             $insertAirport->region_id = Region::where('code', '=', $airport[9])->first()->id;
             $insertAirport->save();
         }
     }
     $this->info('Import Complete! ' . $i . ' Airports Imported.');
 }
Esempio n. 2
0
 public function postAdd(Request $request)
 {
     $airport = $request->input('icao');
     $airportId = Airport::where('icao', $airport)->first();
     $airline = Airline::find(Session::get('airlineId'));
     $airline->airports()->save($airportId);
     return view('staff.airports.dashboard');
 }
Esempio n. 3
0
 /**
  * Handle the event.
  *
  * @param  PirepWasFiled  $event
  * @return void
  */
 public function handle(PirepWasFiled $event)
 {
     if ($event->reProcess === false) {
         // Move the Pilot to their destination field
         $pilot = Pilot::find($event->pirep->booking->pilot->id);
         $newLocation = Airport::find($event->pirep->booking->route->arrivalAirport->id);
         $pilot->location()->associate($newLocation);
         $pilot->save();
         echo "Moved Pilot ID " . $pilot->id . " to Airport " . $newLocation->icao . PHP_EOL;
     }
 }
Esempio n. 4
0
 public function postAdd(Request $request)
 {
     $from = Airport::where('icao', $request->input('from'))->first();
     $to = Airport::where('icao', $request->input('to'))->first();
     $route = new \vAMSYS\Route();
     $route->departure_id = $from->id;
     $route->arrival_id = $to->id;
     $route->route = $request->input('route');
     $route->airline_id = Session::get('airlineId');
     $route->save();
     return view('staff.routes.dashboard');
 }