2019-11-27 22:19:20 +08:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace Modules\Installer\Services\Importer\Importers;
|
|
|
|
|
|
|
|
use App\Models\Rank;
|
|
|
|
use Modules\Installer\Services\Importer\BaseImporter;
|
|
|
|
|
|
|
|
class RankImport extends BaseImporter
|
|
|
|
{
|
2019-12-02 22:57:35 +08:00
|
|
|
protected $table = 'ranks';
|
|
|
|
|
2019-11-27 22:19:20 +08:00
|
|
|
public function run($start = 0)
|
|
|
|
{
|
|
|
|
$this->comment('--- RANK IMPORT ---');
|
|
|
|
|
|
|
|
$count = 0;
|
2019-12-02 22:57:35 +08:00
|
|
|
foreach ($this->db->readRows($this->table, $start) as $row) {
|
2019-11-27 22:19:20 +08:00
|
|
|
$rank = Rank::firstOrCreate(['name' => $row->rank], [
|
|
|
|
'image_url' => $row->rankimage,
|
|
|
|
'hours' => $row->minhours,
|
|
|
|
]);
|
|
|
|
|
|
|
|
$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');
|
|
|
|
}
|
|
|
|
}
|