<?php

namespace App\Console;

use Illuminate\Console\Scheduling\Schedule;
use Illuminate\Foundation\Console\Kernel as ConsoleKernel;
use Illuminate\Support\Facades\Log;

class Kernel extends ConsoleKernel
{
    /**
     * The Artisan commands provided by your application.
     *
     * @var array
     */
    protected $commands = [
        //
    ];

    /**
     * Define the application's command schedule.
     *
     * @param  \Illuminate\Console\Scheduling\Schedule  $schedule
     * @return void
     */
    protected function schedule(Schedule $schedule)
    {

        Log::info('Controllo schedule...');
        // $schedule->command('inspire')->hourly();
        $schedule->command('backup:clean')->daily()->at('02:00')->before(function () {
            Log::info('Running backup:clean command');
        });
        $schedule->command('backup:run')->daily()->at('07:00')->before(function () {
            Log::info('Running backup:run command');
        });
        $schedule->command('order:gmupdate')->everyTenMinutes()->before(function () {
            Log::info('Running order:gmupdate command');
        });
        $schedule->command('product:gmupdate')->daily()->at('02:00')->before(function () {
            Log::info('Running product:gmupdate command');
        });
        $schedule->command('product:used:gmupdate')->daily()->at('04:30')->before(function () {
            Log::info('Running product:used:gmupdate command');
        });
        $schedule->command('product:updateqta')->everyFiveMinutes()->between('8:00', '00:00')->withoutOverlapping()->before(function () {
            Log::info('Running product:updateqta command');
        });
        $schedule->command('product:startday')
            ->daily()->at('08:00')
            ->before(function () {
                Log::info('Running product:startday command');
            });
    }

    /**
     * Register the commands for the application.
     *
     * @return void
     */
    protected function commands()
    {
        $this->load(__DIR__ . '/Commands');

        require base_path('routes/console.php');
    }
}
