Update (home): Fix broken logic

This commit is contained in:
2023-09-24 22:57:54 +08:00
parent 322d680961
commit 8d7ae47036
2 changed files with 17 additions and 8 deletions

View File

@@ -15,7 +15,7 @@ public function home(Request $request)
{
$featured_post = Post::where('status', 'publish')->orderBy('published_at', 'desc')->first();
$latest_posts = Post::where(function ($query) use ($featured_post) {
$query->whereNotIn('id', [$featured_post->id]);
$query->whereNotIn('id', [$featured_post?->id]);
})->where('status', 'publish')->orderBy('published_at', 'desc')->limit(5)->get();
return response(view('front.welcome', compact('featured_post', 'latest_posts')), 200);