comment('--- AIRLINE IMPORT ---'); $count = 0; foreach ($this->db->readRows($this->table, $start) as $row) { $attrs = [ 'iata' => $row->code, 'name' => $row->name, 'active' => $row->enabled, ]; $w = ['icao' => $row->code]; //$airline = Airline::firstOrCreate($w, $attrs); $airline = Airline::create(array_merge($w, $attrs)); $this->idMapper->addMapping('airlines', $row->id, $airline->id); $this->idMapper->addMapping('airlines', $row->code, $airline->id); Log::debug('Mapping '.$row->id.'/'.$row->code.' to ID '.$airline->id); if ($airline->wasRecentlyCreated) { $count++; } } $this->info('Imported '.$count.' airlines'); } }