55 lines
2.1 KiB
PHP
55 lines
2.1 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
use App\Exceptions\GlobalHandler;
|
|
use App\Jobs\DeleteOldResetTokens;
|
|
use App\Jobs\SendMissingOrderReminderJob;
|
|
use App\Jobs\SendReminderMail;
|
|
use App\Jobs\UpdateSlidesStatus;
|
|
use App\Jobs\UpsertShopsPickupExceptionsUsingApiForYear;
|
|
use Domain\Services\PickupSchedulingService;
|
|
use Illuminate\Foundation\Application;
|
|
use Illuminate\Foundation\Configuration\Exceptions;
|
|
use Illuminate\Support\Env;
|
|
use Illuminate\Support\Facades\Date;
|
|
use Sentry\State\HubInterface;
|
|
|
|
return Application::configure(Env::get('APP_BASE_PATH', dirname(__DIR__)))
|
|
->withRouting(
|
|
commands: __DIR__ . '/../routes/console.php',
|
|
channels: __DIR__ . '/../routes/channels.php',
|
|
health: '/up',
|
|
)
|
|
->withSchedule(function ($schedule): void {
|
|
$schedule->job(DeleteOldResetTokens::class)->everyMinute();
|
|
$schedule->job(UpdateSlidesStatus::class)->everyMinute();
|
|
$schedule->job(SendReminderMail::class)->onOneServer()->dailyAt('10:00');
|
|
$schedule->job(SendMissingOrderReminderJob::class)
|
|
->onOneServer()
|
|
->hourly()
|
|
->when(function () {
|
|
$schedulingService = app(PickupSchedulingService::class);
|
|
|
|
$now = Date::now();
|
|
$currentCutoffAt = $schedulingService->currentCutoff();
|
|
$pickupReminderAt = $currentCutoffAt->copy()
|
|
->subDays(SendMissingOrderReminderJob::DAYS_BEFORE_CUTOFF)
|
|
->subHours(SendMissingOrderReminderJob::HOURS_BEFORE_CUTOFF);
|
|
|
|
return $now->isSameHour($pickupReminderAt);
|
|
});
|
|
$schedule->job(UpsertShopsPickupExceptionsUsingApiForYear::class)
|
|
->onOneServer()
|
|
->yearlyOn(11, 1, '7:30');
|
|
})
|
|
->withMiddleware(require __DIR__ . '/middlewares.php')
|
|
->withExceptions(function (Exceptions $exceptions): void {
|
|
$exceptions->reportable(function (\Throwable $e): void {
|
|
if (app()->bound(HubInterface::class)) {
|
|
resolve(HubInterface::class)->captureException($e);
|
|
}
|
|
});
|
|
|
|
GlobalHandler::afterAppBootstrap($exceptions);
|
|
})->create();
|