Update (kernel)

This commit is contained in:
2023-11-20 08:51:38 +08:00
parent 3ed6215b16
commit 9c1d432b8c
7 changed files with 47 additions and 40 deletions

View File

@@ -22,15 +22,12 @@ protected function schedule(Schedule $schedule): void
})->dailyAt('00:00');
$schedule->call(function () {
$future_post = Post::whereNotNull('published_at')->where('status', 'future')->where('published_at', '<=', now())->orderBy('published_at', 'ASC')->first();
$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');
if (! is_null($future_post)) {
PublishIndexPostJob::dispatch($future_post->id)->onQueue('default')->onConnection('default');
}
})->everyMinute();
}

View File

@@ -18,11 +18,11 @@ public function home(Request $request)
// $query->whereNotIn('id', [$featured_post?->id]);
// })->where('status', 'publish')->orderBy('published_at', 'desc')->limit(5)->get();
$featured_posts = Post::where('status', 'publish')->where('published_at', '<=', now())->orderBy('published_at', 'desc')->limit(6)->get();
$featured_posts = Post::where('status', 'publish')->where('published_at', '<=', now())->orderBy('published_at', 'desc')->limit(3)->get();
$latest_posts = Post::where(function ($query) use ($featured_posts) {
$query->whereNotIn('id', $featured_posts->pluck('id')->toArray());
})->where('status', 'publish')->where('published_at', '<=', now())->orderBy('published_at', 'desc')->limit(6)->get();
})->where('status', 'publish')->where('published_at', '<=', now())->orderBy('published_at', 'desc')->limit(9)->get();
return response(view('front.welcome', compact('featured_posts', 'latest_posts')), 200);
}

View File

@@ -76,9 +76,9 @@ public function index(Request $request)
SEOTools::setTitle($title, false);
$posts = Post::with('category')->where('status', 'publish')
->where('published_at', '<=', now())
->orderBy('published_at', 'desc')
->cursorPaginate(10) ?? collect();
->where('published_at', '<=', now())
->orderBy('published_at', 'desc')
->cursorPaginate(10) ?? collect();
// breadcrumb json ld
$listItems = [];
@@ -124,10 +124,10 @@ public function category(Request $request, $category_slug)
// Get the posts associated with these category IDs
$postIds = PostCategory::whereIn('category_id', $categoryIds)->pluck('post_id');
$posts = Post::whereIn('id', $postIds)
->where('published_at', '<=', now())
->where('status', 'publish')
->orderBy('published_at', 'desc')
->cursorPaginate(10);
->where('published_at', '<=', now())
->where('status', 'publish')
->orderBy('published_at', 'desc')
->cursorPaginate(10);
$title = $category->name.' News from FutureWalker';