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'); })->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)) {
{
PublishIndexPostJob::dispatch($future_post->id)->onQueue('default')->onConnection('default'); PublishIndexPostJob::dispatch($future_post->id)->onQueue('default')->onConnection('default');
} }
})->everyMinute(); })->everyMinute();
} }

View File

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

View File

@@ -75,7 +75,7 @@
| |
*/ */
'middleware' => ['web','horizonBasicAuth'], 'middleware' => ['web', 'horizonBasicAuth'],
/* /*
|-------------------------------------------------------------------------- |--------------------------------------------------------------------------

View File

@@ -18,7 +18,8 @@
<div class="w-full bg-dark text-white d-none d-md-block"> <div class="w-full bg-dark text-white d-none d-md-block">
<div class="container-lg text-center py-2"> <div class="container-lg text-center py-2">
@foreach ($categories as $category) @foreach ($categories as $category)
<a href="#" class="text-white mx-3 font-family-roboto-condensed text-uppercase">{{ $category->name }}</a> <a href="#"
class="text-white mx-3 font-family-roboto-condensed text-uppercase">{{ $category->name }}</a>
@endforeach @endforeach
</div> </div>
</div> </div>

View File

@@ -14,7 +14,7 @@
<div> <div>
@foreach ($post->keywords as $keyword) @foreach ($post->keywords as $keyword)
@if($keyword == $post->main_keyword) @if ($keyword == $post->main_keyword)
<span class="badge text-bg-dark me-1">{{ $keyword }}</span> <span class="badge text-bg-dark me-1">{{ $keyword }}</span>
@else @else
<span class="badge text-bg-light border me-1">{{ $keyword }}</span> <span class="badge text-bg-light border me-1">{{ $keyword }}</span>

View File

@@ -32,10 +32,16 @@
class="rounded-4 card-img-top shadow" style="object-fit: cover;"> class="rounded-4 card-img-top shadow" style="object-fit: cover;">
</div> </div>
<div class="card-body px-0"> <div class="card-body px-0">
<h3 class="h4 fw-bold font-family-roboto-condensed"> <h3 class="h4 fw-bold font-family-roboto-condensed mb-0">
<a <a
href="{{ route('front.post', ['category_slug' => $post->category->slug, 'slug' => $post->slug]) }}">{{ $post->title }}</a> href="{{ route('front.post', ['category_slug' => $post->category->slug, 'slug' => $post->slug]) }}">{{ $post->title }}</a>
</h3> </h3>
<div class="mb-0"><small
class="text-secondary">{{ $post->published_at->diffForHumans() }}</small>
<i class="bi bi-dot"></i>
<small
class="text-secondary">{{ markdown_min_read($post->body) }}</small>
</div>
<p>{{ str_first_sentence($post->bites) }}</p> <p>{{ str_first_sentence($post->bites) }}</p>
</div> </div>
</div> </div>
@@ -55,20 +61,20 @@ class="rounded-4 card-img-top shadow" style="object-fit: cover;">
<div class="text-start"> <div class="text-start">
<h2 id="latest-news" class="fw-bold font-family-roboto-condensed mb-3 h2">Latest News</h2> <h2 id="latest-news" class="fw-bold font-family-roboto-condensed mb-3 h2">Latest News</h2>
</div> </div>
<div class="row g-3 mb-4"> <div class="row g-2 mb-4">
@foreach ($latest_posts as $post) @foreach ($latest_posts as $post)
<div class="col-12 col-md-6"> <div class="col-12 col-md-6">
<div class="card bg-white border-0 shadow" style="height:100%;"> <div class="card bg-white border-0 shadow" style="height:100%;">
<div class="card-body d-flex"> <div class="card-body d-flex p-2 p-lg-3">
<div class="row align-self-center"> <div class="row align-self-center">
<div class="col-12 col-lg-5 d-flex py-1" style="height:100%;"> <div class="col-3 col-lg-5 d-flex py-1" style="height:100%;">
<div class="align-self-center"> <div class="align-self-center">
<img class="img-fluid rounded-4" src="{{ $post->featured_image }}" <img class="img-fluid rounded-2" src="{{ $post->featured_image }}"
alt="{{ $post->title }}"> alt="{{ $post->title }}">
</div> </div>
</div> </div>
<div class="col-12 col-lg-7 d-flex py-1" style="height:100%;"> <div class="col-9 col-lg-7 d-flex py-1" style="height:100%;">
<div class="align-self-center"> <div class="align-self-center">
<div class=""> <div class="">
<h3 class="h6 mb-0 fw-bold font-family-roboto-condensed"> <h3 class="h6 mb-0 fw-bold font-family-roboto-condensed">
@@ -82,6 +88,9 @@ class="fw-bold"
</div> </div>
<div><small <div><small
class="text-secondary">{{ $post->published_at->diffForHumans() }}</small> class="text-secondary">{{ $post->published_at->diffForHumans() }}</small>
<i class="bi bi-dot"></i>
<small
class="text-secondary">{{ markdown_min_read($post->body) }}</small>
</div> </div>
</div> </div>