From e2b2bd63da2762e7172d3bb0d84f76dd85c00d43 Mon Sep 17 00:00:00 2001 From: Charles Teh Date: Mon, 20 Nov 2023 01:48:47 +0800 Subject: [PATCH] Update (kernel) --- app/Console/Kernel.php | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/app/Console/Kernel.php b/app/Console/Kernel.php index 321dc33..b40f5ac 100644 --- a/app/Console/Kernel.php +++ b/app/Console/Kernel.php @@ -24,7 +24,12 @@ protected function schedule(Schedule $schedule): void $schedule->call(function () { $future_post = Post::whereNotNull('published_at')->where('status', 'future')->where('published_at', '>=', now())->orderBy('published_at', 'ASC')->first(); - PublishIndexPostJob::dispatch($future_post->id)->onQueue('default')->onConnection('default'); + if (!is_null($future_post)) + { + PublishIndexPostJob::dispatch($future_post->id)->onQueue('default')->onConnection('default'); + } + + })->everyMinute();