<?php

declare(strict_types=1);

namespace App\Providers;

use Illuminate\Console\Scheduling\Schedule;
use Illuminate\Support\ServiceProvider;

/**
 * Class ScheduleServiceProvider
 *
 * @package App\Providers
 */
final class ScheduleServiceProvider extends ServiceProvider
{
    /**
     * @return void
     */
    public function boot(): void
    {
        $this->callAfterResolving(Schedule::class, function (Schedule $schedule) {
            $schedule
                ->command('queue:retry all')
                ->everyThirtyMinutes()
                ->withoutOverlapping(10)
                ->onOneServer()
                ->runInBackground()
                ->emailOutputOnFailure('logs@seka.sk');

            // Kontrola kazdu minutu pre presne zverejnenie informacii
            $schedule
                ->command('informacie:publish-scheduled')
                ->everyMinute()
                ->withoutOverlapping()
                ->runInBackground()
                ->emailOutputOnFailure('logs@seka.sk');

            $schedule
                ->command('notifikacia:overenie-platnosti-tokenov --odstranit-neplatne')
                ->withoutOverlapping()
                ->runInBackground()
                ->dailyAt('04:00')
                ->emailOutputTo('logs@seka.sk');
        });
    }
}
