2016-09-01 16:23:39 +01:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace App\Console;
|
|
|
|
|
2016-09-02 21:27:50 +01:00
|
|
|
use App\Console\Commands\ProcessUploadCommand;
|
|
|
|
use App\Upload;
|
2016-09-01 16:23:39 +01:00
|
|
|
use Illuminate\Console\Scheduling\Schedule;
|
|
|
|
use Illuminate\Foundation\Console\Kernel as ConsoleKernel;
|
|
|
|
|
|
|
|
class Kernel extends ConsoleKernel
|
|
|
|
{
|
|
|
|
/**
|
|
|
|
* The Artisan commands provided by your application.
|
|
|
|
*
|
|
|
|
* @var array
|
|
|
|
*/
|
|
|
|
protected $commands = [
|
2016-09-02 21:27:50 +01:00
|
|
|
ProcessUploadCommand::class
|
2016-09-01 16:23:39 +01:00
|
|
|
];
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Define the application's command schedule.
|
|
|
|
*
|
|
|
|
* @param \Illuminate\Console\Scheduling\Schedule $schedule
|
|
|
|
* @return void
|
|
|
|
*/
|
|
|
|
protected function schedule(Schedule $schedule)
|
|
|
|
{
|
2016-09-02 21:27:50 +01:00
|
|
|
$schedule->command('twilight:process-uploads')
|
|
|
|
->everyMinute()
|
|
|
|
->when(function () {
|
2016-09-05 12:01:30 +01:00
|
|
|
return (Upload::where([
|
|
|
|
'is_completed' => 0,
|
|
|
|
'is_processing' => 0,
|
|
|
|
'is_ready' => 1
|
|
|
|
])->count() > 0);
|
2016-09-02 21:27:50 +01:00
|
|
|
});
|
2016-09-01 16:23:39 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Register the Closure based commands for the application.
|
|
|
|
*
|
|
|
|
* @return void
|
|
|
|
*/
|
|
|
|
protected function commands()
|
|
|
|
{
|
|
|
|
require base_path('routes/console.php');
|
|
|
|
}
|
|
|
|
}
|