Enhance nodelist import

This commit is contained in:
Deon George
2021-08-21 21:15:22 +10:00
parent 68a10af776
commit 8c992ad0f9
7 changed files with 210 additions and 55 deletions

View File

@@ -2,10 +2,8 @@
namespace App\Console\Commands;
use Carbon\Carbon;
use Illuminate\Console\Command;
use App\Models\{Domain,Nodelist};
use App\Jobs\NodelistImport as Job;
class NodelistImport extends Command
@@ -16,9 +14,9 @@ class NodelistImport extends Command
* @var string
*/
protected $signature = 'nodelist:import'
.' {domain : Domain Name}'
.' {file : Nodelist File}'
.' {--D|delete : Delete old data for the date}';
.' {--D|delete : Delete old data for the date}'
.' {--U|unlink : Delete file after import}';
/**
* The console command description.
@@ -27,16 +25,6 @@ class NodelistImport extends Command
*/
protected $description = 'Import Nodelist';
/**
* Create a new command instance.
*
* @return void
*/
public function __construct()
{
parent::__construct();
}
/**
* Execute the console command.
*
@@ -44,9 +32,6 @@ class NodelistImport extends Command
*/
public function handle()
{
$do = Domain::where('name',$this->argument('domain'))->singleOrFail();
$o = Nodelist::firstOrCreate(['date'=>Carbon::now(),'domain_id'=>$do->id]);
return Job::dispatchSync($do,$o,$this->argument('file'),$this->option('delete'));
return Job::dispatchSync($this->argument('file'),$this->option('delete'),$this->option('unlink'));
}
}