61 lines
2 KiB
PHP
61 lines
2 KiB
PHP
<?php
|
|
|
|
namespace App\Console\Commands;
|
|
|
|
use App\Jobs\ProcessExportCodesUniques as ProcessExportCodesUniquesJob;
|
|
use Illuminate\Console\Command;
|
|
|
|
class ProcessExportCodesUniques extends Command
|
|
{
|
|
/**
|
|
* The name and signature of the console command.
|
|
*
|
|
* @var string
|
|
*/
|
|
protected $signature = 'app:process-export-codes-uniques';
|
|
|
|
/**
|
|
* The console command description.
|
|
*
|
|
* @var string
|
|
*/
|
|
protected $description = 'Command description';
|
|
|
|
/**
|
|
* Execute the console command.
|
|
*/
|
|
public function handle()
|
|
{
|
|
// Nombre total de code à exporter.
|
|
$nbCodeTot = $this->ask("Combien de code doivent être exporté ?");
|
|
while (empty(intval($nbCodeTot)) || !is_int(intval($nbCodeTot))) {
|
|
$this->info("Valeur incorrect, veuillez entrer un nombre entier.");
|
|
$nbCodeTot = $this->ask("Veuillez entrer une nouvelle valeur");
|
|
}
|
|
$nbCodeTot = intval($nbCodeTot);
|
|
|
|
// Nombre de code par fichier.
|
|
$nbCodeFic = $this->ask("Combien de code par fichier ?");
|
|
while (empty(intval($nbCodeFic)) || !is_int(intval($nbCodeFic))) {
|
|
$this->info("Valeur incorrect, veuillez entrer un nombre entier.");
|
|
$nbCodeFic = $this->ask("Veuillez entrer une nouvelle valeur");
|
|
}
|
|
$nbCodeFic = intval($nbCodeFic);
|
|
|
|
// Nombre de code par ligne.
|
|
$nbCodeLigne = $this->ask("Combien de code par ligne dans un fichier ?");
|
|
while (empty(intval($nbCodeLigne)) || !is_int(intval($nbCodeLigne))) {
|
|
$this->info("Valeur incorrect, veuillez entrer un nombre entier.");
|
|
$nbCodeLigne = $this->ask("Veuillez entrer une nouvelle valeur");
|
|
}
|
|
$nbCodeLigne = intval($nbCodeLigne);
|
|
|
|
$this->info("Traitement en cours, veuillez patienter...");
|
|
|
|
$job = new ProcessExportCodesUniquesJob($nbCodeFic, $nbCodeTot, $nbCodeLigne);
|
|
$job->handle();
|
|
|
|
$this->info("Fin du traitement, creation de l'archive...");
|
|
return 0;
|
|
}
|
|
}
|