2019-11-27 22:19:20 +08:00
|
|
|
<?php
|
|
|
|
|
2019-12-13 04:07:35 +08:00
|
|
|
namespace Modules\Importer\Services\Importers;
|
2019-11-27 22:19:20 +08:00
|
|
|
|
|
|
|
use App\Models\Rank;
|
2019-12-13 04:07:35 +08:00
|
|
|
use Modules\Importer\Services\BaseImporter;
|
2019-11-27 22:19:20 +08:00
|
|
|
|
|
|
|
class RankImport extends BaseImporter
|
|
|
|
{
|
2019-12-02 22:57:35 +08:00
|
|
|
protected $table = 'ranks';
|
2020-02-24 08:48:28 +08:00
|
|
|
protected $idField = 'rankid';
|
2019-12-02 22:57:35 +08:00
|
|
|
|
2019-11-27 22:19:20 +08:00
|
|
|
public function run($start = 0)
|
|
|
|
{
|
|
|
|
$this->comment('--- RANK IMPORT ---');
|
|
|
|
|
|
|
|
$count = 0;
|
2020-02-24 08:48:28 +08:00
|
|
|
$rows = $this->db->readRows($this->table, $this->idField, $start);
|
|
|
|
foreach ($rows as $row) {
|
2020-02-26 03:45:23 +08:00
|
|
|
$rank = Rank::updateOrCreate(['name' => $row->rank], [
|
2020-02-25 06:52:49 +08:00
|
|
|
'image_url' => $row->rankimage,
|
|
|
|
'hours' => $row->minhours,
|
|
|
|
'acars_base_payrate' => $row->payrate,
|
|
|
|
'manual_base_payrate' => $row->payrate,
|
2020-01-07 02:44:43 +08:00
|
|
|
]);
|
2019-11-27 22:19:20 +08:00
|
|
|
|
|
|
|
$this->idMapper->addMapping('ranks', $row->rankid, $rank->id);
|
|
|
|
$this->idMapper->addMapping('ranks', $row->rank, $rank->id);
|
|
|
|
|
|
|
|
if ($rank->wasRecentlyCreated) {
|
|
|
|
$count++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
$this->info('Imported '.$count.' ranks');
|
|
|
|
}
|
|
|
|
}
|