45 lines
1.2 KiB
PHP
45 lines
1.2 KiB
PHP
<?php
|
|
|
|
namespace App\Console;
|
|
|
|
use App\Jobs\BrowseAndWriteWithAIJob;
|
|
use App\Jobs\PublishIndexPostJob;
|
|
use App\Models\Post;
|
|
use Illuminate\Console\Scheduling\Schedule;
|
|
use Illuminate\Foundation\Console\Kernel as ConsoleKernel;
|
|
|
|
class Kernel extends ConsoleKernel
|
|
{
|
|
/**
|
|
* Define the application's command schedule.
|
|
*/
|
|
protected function schedule(Schedule $schedule): void
|
|
{
|
|
$schedule->command('sitemap:generate')->daily();
|
|
|
|
$schedule->call(function () {
|
|
BrowseAndWriteWithAIJob::dispatch()->onQueue('default')->onConnection('default');
|
|
})->dailyAt('00:00');
|
|
|
|
$schedule->call(function () {
|
|
$future_post = Post::whereNotNull('published_at')->where('status', 'future')->where('published_at', '>=', now())->orderBy('published_at', 'ASC')->first();
|
|
|
|
if (! is_null($future_post)) {
|
|
PublishIndexPostJob::dispatch($future_post->id)->onQueue('default')->onConnection('default');
|
|
}
|
|
|
|
})->everyMinute();
|
|
|
|
}
|
|
|
|
/**
|
|
* Register the commands for the application.
|
|
*/
|
|
protected function commands(): void
|
|
{
|
|
$this->load(__DIR__.'/Commands');
|
|
|
|
require base_path('routes/console.php');
|
|
}
|
|
}
|