41 lines
1.1 KiB
PHP
41 lines
1.1 KiB
PHP
<?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
|
|
{
|
|
$year = $this->argument('year');
|
|
|
|
if ($year !== null && is_numeric($year) === false) {
|
|
$this->error('The year must be a number');
|
|
|
|
return self::FAILURE;
|
|
}
|
|
|
|
$this->info('Fetching hollidays upsert shops exceptions using Api');
|
|
|
|
$job = $year !== null
|
|
? new UpsertShopsPickupExceptionsUsingApiForYear(intval($year))
|
|
: new UpsertShopsPickupExceptionsUsingApiForYear();
|
|
|
|
dispatch($job);
|
|
|
|
$this->info('Done');
|
|
|
|
return self::SUCCESS;
|
|
}
|
|
}
|