phpvms/modules/Importer/Services/Importers/RankImport.php
Nabeel S 14aacdfb75
Import expense and ledger entries #443 (#588)
* Fix rank importing with PIREP pay #443

* Import ledger information #443

* Uncomment out testing importers

* Import expense log and settings #443

* Formatting
2020-02-25 14:45:23 -05:00

38 lines
1.0 KiB
PHP

<?php
namespace Modules\Importer\Services\Importers;
use App\Models\Rank;
use Modules\Importer\Services\BaseImporter;
class RankImport extends BaseImporter
{
protected $table = 'ranks';
protected $idField = 'rankid';
public function run($start = 0)
{
$this->comment('--- RANK IMPORT ---');
$count = 0;
$rows = $this->db->readRows($this->table, $this->idField, $start);
foreach ($rows as $row) {
$rank = Rank::updateOrCreate(['name' => $row->rank], [
'image_url' => $row->rankimage,
'hours' => $row->minhours,
'acars_base_payrate' => $row->payrate,
'manual_base_payrate' => $row->payrate,
]);
$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');
}
}