ldc-cocotte/app/Console/Commands/UpsertPublicHolydaysOnShopsPickupExceptions.php

42 lines
1.1 KiB
PHP
Raw Permalink Normal View History

2026-06-14 21:32:07 +02:00
<?php
declare(strict_types=1);
namespace App\Console\Commands;
use App\Jobs\UpsertShopsPickupExceptionsUsingApiForYear;
use Illuminate\Console\Attributes\Description;
use Illuminate\Console\Attributes\Signature;
use Illuminate\Console\Command;
#[Description('fetch the public holiday for a specific year or by default for the next year')]
#[Signature('uwil:upsert-shops-hollydays {year?}')]
class UpsertPublicHolydaysOnShopsPickupExceptions extends Command
{
/**
* Execute the console command.
*/
public function handle(): int
2026-06-14 21:32:07 +02:00
{
$year = $this->argument('year');
if ($year !== null && is_numeric($year) === false) {
2026-06-14 21:32:07 +02:00
$this->error('The year must be a number');
return self::FAILURE;
2026-06-14 21:32:07 +02:00
}
$this->info('Fetching hollidays upsert shops exceptions using Api');
$job = $year !== null
? new UpsertShopsPickupExceptionsUsingApiForYear(intval($year))
: new UpsertShopsPickupExceptionsUsingApiForYear();
dispatch($job);
2026-06-14 21:32:07 +02:00
$this->info('Done');
return self::SUCCESS;
2026-06-14 21:32:07 +02:00
}
}