lthn.io/app/Mod/Names/Boot.php

46 lines
1.3 KiB
PHP
Raw Permalink Normal View History

<?php
declare(strict_types=1);
namespace Mod\Names;
use Core\Events\ApiRoutesRegistering;
use Core\Events\ConsoleBooting;
use Core\Events\WebRoutesRegistering;
use Illuminate\Console\Scheduling\Schedule;
use Illuminate\Support\Facades\Route;
use Mod\Names\Commands\RetryDnsTickets;
class Boot
{
public static array $listens = [
WebRoutesRegistering::class => 'onWebRoutes',
ApiRoutesRegistering::class => 'onApiRoutes',
ConsoleBooting::class => 'onConsole',
];
public function onWebRoutes(WebRoutesRegistering $event): void
{
$event->views('names', __DIR__ . '/Views');
$event->routes(fn () => Route::prefix('names')->group(__DIR__ . '/Routes/web.php'));
}
public function onApiRoutes(ApiRoutesRegistering $event): void
{
$event->routes(fn () => Route::prefix('v1/names')->group(__DIR__ . '/Routes/api.php'));
}
public function onConsole(ConsoleBooting $event): void
{
$event->command(RetryDnsTickets::class);
$event->command(Commands\SetupWorkspace::class);
app()->booted(function () {
app(Schedule::class)->command('names:retry-dns')
->everyMinute()
->withoutOverlapping()
->runInBackground();
});
}
}