@extends('frontend.theme1.index', ['title' => ($categoryTitle ?? 'Media Category') . ' - Fitness Plus Indonesia', 'count' => $count ?? 0]) @section('content') @php $newsCollection = $news ?? collect(); @endphp

{{ $categoryTitle }}

Media
@if (!empty($search))

Hasil pencarian untuk: {{ $search }}

@endif
@forelse ($newsCollection as $item) @php $publishedAt = $item->published_at ?? $item->created_at; $imagePath = trim((string) ($item->image ?? '')); $itemUrl = !empty($item->slug) ? route('media.detail', ['slug' => $item->slug]) : '#'; $imageUrl = $imagePath !== '' ? (\Illuminate\Support\Str::startsWith($imagePath, ['http://', 'https://', '//']) ? $imagePath : asset(ltrim($imagePath, '/'))) : asset('themes1/images/class/frame1.png'); $summary = \Illuminate\Support\Str::limit( trim((string) preg_replace('/\s+/', ' ', strip_tags((string) ($item->content ?? '')))), 118 ); $label = $item->tag ?: (optional($item->newsCategory)->name_category ?: 'Media'); @endphp
{{ $item->title }}
@if ($publishedAt)

{{ $publishedAt->format('l, j M Y') }}

@endif

{{ $item->title }}

{{ $summary }}

{{ $label }}
@empty

{{ !empty($search) ? 'Hasil tidak ditemukan' : 'Konten belum tersedia' }}

{{ !empty($search) ? 'Coba kata kunci lain untuk mencari artikel.' : 'Data media untuk kategori ini belum tersedia.' }}

@endforelse
@if ($newsCollection->lastPage() > 1) @php $currentPage = $newsCollection->currentPage(); $lastPage = $newsCollection->lastPage(); $pageLinks = []; if ($lastPage <= 7) { $pageLinks = range(1, $lastPage); } else { $pageLinks[] = 1; if ($currentPage > 4) { $pageLinks[] = 'ellipsis-left'; } $start = max(2, $currentPage - 1); $end = min($lastPage - 1, $currentPage + 1); if ($currentPage <= 4) { $start = 2; $end = 4; } elseif ($currentPage >= $lastPage - 3) { $start = $lastPage - 3; $end = $lastPage - 1; } for ($i = $start; $i <= $end; $i++) { if ($i > 1 && $i < $lastPage) { $pageLinks[] = $i; } } if ($currentPage < $lastPage - 3) { $pageLinks[] = 'ellipsis-right'; } $pageLinks[] = $lastPage; } @endphp @endif
@endsection