Update (home): Fix broken logic
This commit is contained in:
@@ -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);
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
@extends('front.layouts.app')
|
||||
@section('content')
|
||||
<main class="container">
|
||||
@if(!is_null($featured_post))
|
||||
<div class="p-4 p-md-5 mb-4 rounded text-body-emphasis bg-body-secondary">
|
||||
<div class="col-lg-12 px-0">
|
||||
<h1 class="display-4 fst-italic">{{ $featured_post->title }}</h1>
|
||||
@@ -9,18 +10,26 @@
|
||||
class=" fw-bold">Continue reading...</a></p>
|
||||
</div>
|
||||
</div>
|
||||
@endif
|
||||
|
||||
|
||||
<div class="row g-5">
|
||||
<div class="col-md-8">
|
||||
@foreach ($latest_posts as $post)
|
||||
@include('front.partials.post_detail', ['post' => $post])
|
||||
@endforeach
|
||||
|
||||
<div class="w-100 d-flex justify-content-center">
|
||||
<a class="btn btn-outline-primary rounded-pill px-3 text-decoration-none"
|
||||
href="{{ route('front.all') }}">View Latest News</a>
|
||||
</div>
|
||||
@if($latest_posts->count() > 0)
|
||||
@foreach ($latest_posts as $post)
|
||||
@include('front.partials.post_detail', ['post' => $post])
|
||||
@endforeach
|
||||
|
||||
<div class="w-100 d-flex justify-content-center">
|
||||
<a class="btn btn-outline-primary rounded-pill px-3 text-decoration-none"
|
||||
href="{{ route('front.all') }}">View Latest News</a>
|
||||
</div>
|
||||
@else
|
||||
<div class="py-3 text-center">
|
||||
<div class="mb-2">No posts found yet.</div>
|
||||
</div>
|
||||
@endif
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user