phpvms/modules/Installer/Services/Importer/Importers/RankImport.php
Nabeel S 68eff40753
Replace importer with AJAX powered; better error handling #443 (#447)
* Replace importer with AJAX powered; better error handling #443

* Formatting

* Fix command line importer
2019-12-02 09:57:35 -05:00

34 lines
887 B
PHP

<?php
namespace Modules\Installer\Services\Importer\Importers;
use App\Models\Rank;
use Modules\Installer\Services\Importer\BaseImporter;
class RankImport extends BaseImporter
{
protected $table = 'ranks';
public function run($start = 0)
{
$this->comment('--- RANK IMPORT ---');
$count = 0;
foreach ($this->db->readRows($this->table, $start) as $row) {
$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');
}
}