<?php

namespace App\Console;

use Illuminate\Console\Scheduling\Schedule;
use Illuminate\Foundation\Console\Kernel as ConsoleKernel;
use Illuminate\Support\Facades\DB;
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)
    {
        // $schedule->command('inspire')
        //          ->hourly();

        $schedule->call(function (){
//            $monolog = Log::getMonolog();
//            $monolog->popHandler();
//            Log::useFiles(storage_path('logs/job/error.log'));
//            Log::info('test');

            $data=DB::table('fail')->where('season','=',20)
                ->where('status','=',1)
                ->where('type','=',1)
                ->select('number','id')
                ->get();
            foreach ($data as $k=>$v){
                $re=DB::table('inte_review')->where('season','=',20)
                    ->where('number',$v->number)->first();
                if (!$re){
                    DB::table('review_log')->insert(['number'=>$v->number,'inte_id'=>$v->id]);
                }
            }
        })->everyMinute();
    }

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

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


}
