ldc-cocotte/app/Console/Commands/SyncProductIncosCommand.php
Jérémy Munsch d0efb0f527
refactor: update namespaces for actions and queries
Refactored the codebase to change the namespaces of various actions and queries from `App\Actions` to `App\Cqs\Actions` and `App\Queries` to `App\Cqs\Queries`. This restructuring improves organization and clarity in the codebase.
2026-11-10 15:13:26 +01:00

38 lines
1.3 KiB
PHP

<?php
declare(strict_types=1);
namespace App\Console\Commands;
use App\Cqs\Actions\ProductIncos\SynchronizeProductIncosWithArcadiaApi;
use App\Contracts\ActionInputEmpty;
use App\Contracts\Executor;
use App\Jobs\FetchAndUpsertArcadiaProductIncos;
use Illuminate\Console\Attributes\Description;
use Illuminate\Console\Attributes\Signature;
use Illuminate\Console\Command;
#[Description('Synchronize all product INCO sheets with Arcadia API')]
#[Signature('uwil:incos:sync {--queue : Dispatch the synchronization job to the queue}')]
class SyncProductIncosCommand extends Command
{
public function handle(
Executor $executor,
SynchronizeProductIncosWithArcadiaApi $action
): int {
if ($this->option('queue')) {
$this->info('Dispatching FetchAndUpsertArcadiaProductIncos job to queue...');
FetchAndUpsertArcadiaProductIncos::dispatch();
$this->info('Job dispatched.');
return self::SUCCESS;
}
$this->info('Starting synchronous INCO synchronization with Arcadia API...');
/** @var int $count */
$count = $executor->execute($action, new ActionInputEmpty());
$this->info("Successfully synchronized {$count} INCO sheets.");
return self::SUCCESS;
}
}