From 9c1d432b8c7a68488222beaf36dfd3e7721b4dbc Mon Sep 17 00:00:00 2001 From: Charles Teh Date: Mon, 20 Nov 2023 08:51:38 +0800 Subject: [PATCH] Update (kernel) --- app/Console/Kernel.php | 9 +++---- .../Controllers/Front/FrontHomeController.php | 4 ++-- .../Controllers/Front/FrontListController.php | 14 +++++------ config/horizon.php | 2 +- .../front/layouts/partials/nav.blade.php | 13 +++++----- resources/views/front/single_post.blade.php | 24 +++++++++---------- resources/views/front/welcome.blade.php | 21 +++++++++++----- 7 files changed, 47 insertions(+), 40 deletions(-) diff --git a/app/Console/Kernel.php b/app/Console/Kernel.php index 7d3441a..108d236 100644 --- a/app/Console/Kernel.php +++ b/app/Console/Kernel.php @@ -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(); } diff --git a/app/Http/Controllers/Front/FrontHomeController.php b/app/Http/Controllers/Front/FrontHomeController.php index 18cc00e..64f1602 100644 --- a/app/Http/Controllers/Front/FrontHomeController.php +++ b/app/Http/Controllers/Front/FrontHomeController.php @@ -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); } diff --git a/app/Http/Controllers/Front/FrontListController.php b/app/Http/Controllers/Front/FrontListController.php index ebfc8dd..4fcff81 100644 --- a/app/Http/Controllers/Front/FrontListController.php +++ b/app/Http/Controllers/Front/FrontListController.php @@ -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'; diff --git a/config/horizon.php b/config/horizon.php index 159f021..0543b8c 100644 --- a/config/horizon.php +++ b/config/horizon.php @@ -75,7 +75,7 @@ | */ - 'middleware' => ['web','horizonBasicAuth'], + 'middleware' => ['web', 'horizonBasicAuth'], /* |-------------------------------------------------------------------------- diff --git a/resources/views/front/layouts/partials/nav.blade.php b/resources/views/front/layouts/partials/nav.blade.php index f50ce41..fd66995 100644 --- a/resources/views/front/layouts/partials/nav.blade.php +++ b/resources/views/front/layouts/partials/nav.blade.php @@ -16,9 +16,10 @@
-
- @foreach ($categories as $category) - {{ $category->name }} - @endforeach -
-
+
+ @foreach ($categories as $category) + {{ $category->name }} + @endforeach +
+ diff --git a/resources/views/front/single_post.blade.php b/resources/views/front/single_post.blade.php index 652e2c1..5fcac52 100644 --- a/resources/views/front/single_post.blade.php +++ b/resources/views/front/single_post.blade.php @@ -9,19 +9,19 @@
-
-

{{ $post->title }}

+
+

{{ $post->title }}

-
- @foreach ($post->keywords as $keyword) - @if($keyword == $post->main_keyword) - {{ $keyword }} - @else - {{ $keyword }} - @endif - @endforeach -
-
+
+ @foreach ($post->keywords as $keyword) + @if ($keyword == $post->main_keyword) + {{ $keyword }} + @else + {{ $keyword }} + @endif + @endforeach +
+
diff --git a/resources/views/front/welcome.blade.php b/resources/views/front/welcome.blade.php index 542d56a..2fb8637 100644 --- a/resources/views/front/welcome.blade.php +++ b/resources/views/front/welcome.blade.php @@ -32,10 +32,16 @@ class="rounded-4 card-img-top shadow" style="object-fit: cover;">
-

+

{{ $post->title }}

+
{{ $post->published_at->diffForHumans() }} + + {{ markdown_min_read($post->body) }} +

{{ str_first_sentence($post->bites) }}

@@ -55,20 +61,20 @@ class="rounded-4 card-img-top shadow" style="object-fit: cover;">

Latest News

-
+
@foreach ($latest_posts as $post)
-
+
-
+
- {{ $post->title }}
-
+

@@ -82,6 +88,9 @@ class="fw-bold"

{{ $post->published_at->diffForHumans() }} + + {{ markdown_min_read($post->body) }}