37 lines
1.3 KiB
PHP
37 lines
1.3 KiB
PHP
@php
|
|
use App\Models\Publication;
|
|
|
|
$limit = (int) ($block->content['limit'] ?? 6);
|
|
$heading = $block->content['title'] ?? null;
|
|
$filterChannelId = $block->content['channel_id'] ?? null;
|
|
$filterTermId = $block->content['taxonomy_term_id'] ?? null;
|
|
|
|
$query = Publication::published()
|
|
->forChannel($filterChannelId ? \App\Models\Channel::find($filterChannelId) ?? $channel : $channel)
|
|
->with(['post.author', 'channel.prefixes'])
|
|
->latest('published_at');
|
|
|
|
if ($filterTermId) {
|
|
$query->whereHas('taxonomyTerms', fn($q) => $q->where('taxonomy_terms.id', $filterTermId));
|
|
}
|
|
|
|
$posts = $query->limit($limit)->get();
|
|
@endphp
|
|
|
|
@if($posts->isNotEmpty())
|
|
<div class="my-8">
|
|
@if($heading)
|
|
<h3 class="text-xl font-semibold mb-4">{{ $heading }}</h3>
|
|
@endif
|
|
|
|
<div class="flex gap-4 overflow-x-auto pb-2">
|
|
@foreach($posts as $post)
|
|
<a href="{{ $post->url }}"
|
|
class="flex-none w-56 rounded border border-gray-200 p-4 hover:border-gray-400 transition">
|
|
<p class="font-medium leading-snug line-clamp-2">{{ $post->title }}</p>
|
|
<p class="mt-2 text-xs text-gray-400">{{ $post->published_at->format('d M Y') }}</p>
|
|
</a>
|
|
@endforeach
|
|
</div>
|
|
</div>
|
|
@endif
|