d2d.emegrendeles.hu/app/Console/Commands/PricelistProcessCommand.php

50 lines
1.4 KiB
PHP

<?php
namespace App\Console\Commands;
use App\Models\PricelistFile;
use App\Services\PricelistFileProcessService;
use Illuminate\Console\Command;
class PricelistProcessCommand extends Command
{
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'pricelist:process {id}';
/**
* The console command description.
*
* @var string
*/
protected $description = 'Elindítja a megadott azonosítójú árlista fájl kezdeti feldolgozási láncát (Pre-process -> Validation)';
/**
* Execute the console command.
*/
public function handle(PricelistFileProcessService $service): int
{
$id = $this->argument('id');
$pricelistFile = PricelistFile::find($id);
if (!$pricelistFile) {
$this->error("A(z) {$id} ID-vel rendelkező árlista fájl nem található.");
return 1;
}
$this->info("Folyamat elindítása: {$pricelistFile->filename} (ID: {$id})");
try {
$service->dispatchInitialChain($pricelistFile);
$this->info("Az árlista feldolgozási lánc (Pre-process -> Validation) sikeresen ütemezve.");
return 0;
} catch (\Exception $e) {
$this->error("Hiba történt a folyamat indításakor: " . $e->getMessage());
return 1;
}
}
}