This commit is contained in:
2023-11-20 02:42:54 +08:00
parent b929cae31e
commit 36f0588ef8
3 changed files with 25 additions and 4 deletions

View File

@@ -22,7 +22,7 @@ protected function schedule(Schedule $schedule): void
})->dailyAt('00:00'); })->dailyAt('00:00');
$schedule->call(function () { $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)) if (!is_null($future_post))
{ {

View File

@@ -37,6 +37,7 @@ public function search(Request $request)
$posts = Post::with('category') $posts = Post::with('category')
->where('status', 'publish') ->where('status', 'publish')
->whereRaw("to_tsvector('english', title || ' ' || bites) @@ to_tsquery('english', ?)", [$query]) ->whereRaw("to_tsvector('english', title || ' ' || bites) @@ to_tsquery('english', ?)", [$query])
->where('published_at', '<=', now())
->orderBy('published_at', 'desc') ->orderBy('published_at', 'desc')
->cursorPaginate(10); ->cursorPaginate(10);
@@ -74,7 +75,10 @@ public function index(Request $request)
SEOTools::jsonLd(); SEOTools::jsonLd();
SEOTools::setTitle($title, false); SEOTools::setTitle($title, false);
$posts = Post::with('category')->where('status', 'publish')->orderBy('published_at', 'desc')->cursorPaginate(10) ?? collect(); $posts = Post::with('category')->where('status', 'publish')
->where('published_at', '<=', now())
->orderBy('published_at', 'desc')
->cursorPaginate(10) ?? collect();
// breadcrumb json ld // breadcrumb json ld
$listItems = []; $listItems = [];
@@ -119,7 +123,11 @@ public function category(Request $request, $category_slug)
// Get the posts associated with these category IDs // Get the posts associated with these category IDs
$postIds = PostCategory::whereIn('category_id', $categoryIds)->pluck('post_id'); $postIds = PostCategory::whereIn('category_id', $categoryIds)->pluck('post_id');
$posts = Post::whereIn('id', $postIds)->where('status', 'publish')->orderBy('published_at', 'desc')->cursorPaginate(10); $posts = Post::whereIn('id', $postIds)
->where('published_at', '<=', now())
->where('status', 'publish')
->orderBy('published_at', 'desc')
->cursorPaginate(10);
$title = $category->name.' News from FutureWalker'; $title = $category->name.' News from FutureWalker';

View File

@@ -9,7 +9,20 @@
<article class="blog-post <article class="blog-post
"> ">
<h1 class="fw-bold font-family-roboto-condensed mb-3">{{ $post->title }}</h1> <div class="mb-2">
<h1 class="fw-bold font-family-roboto-condensed mb-1">{{ $post->title }}</h1>
<div>
@foreach ($post->keywords as $keyword)
@if($keyword == $post->main_keyword)
<span class="badge text-bg-dark me-1">{{ $keyword }}</span>
@else
<span class="badge text-bg-light border me-1">{{ $keyword }}</span>
@endif
@endforeach
</div>
</div>
<div class="mb-2 text-secondary"> <div class="mb-2 text-secondary">
<small>{{ $post->published_at->format('jS F Y') }}</small> <small>{{ $post->published_at->format('jS F Y') }}</small>