@extends('frontend.theme1.index', ['title' => 'Media - Fitness Plus Indonesia', 'count' => $count ?? 0]) @section('css') @endsection @section('js') @endsection @section('content') @php $newsCollection = collect($news ?? [])->values(); $activeCategory = strtolower(trim((string) ($selectedCategory ?? ''))); $articleNews = $newsCollection ->filter(function ($item) { $categoryName = \Illuminate\Support\Str::lower((string) optional($item->newsCategory)->name_category); $categorySlug = \Illuminate\Support\Str::lower((string) optional($item->newsCategory)->slug); return $categoryName === 'artikel' || $categorySlug === 'artikel'; }) ->take(3) ->values(); $companyNews = $newsCollection ->filter(function ($item) { $categoryName = \Illuminate\Support\Str::lower((string) optional($item->newsCategory)->name_category); $categorySlug = \Illuminate\Support\Str::lower((string) optional($item->newsCategory)->slug); return $categoryName === 'berita perusahaan' || $categorySlug === 'berita-perusahaan'; }) ->take(3) ->values(); if ($activeCategory === '' && $articleNews->isEmpty()) { $articleNews = $newsCollection->take(3)->values(); } if ($activeCategory === '' && $companyNews->isEmpty()) { $usedIds = $articleNews->pluck('id')->filter()->all(); $companyNews = $newsCollection ->reject(fn ($item) => in_array($item->id, $usedIds, true)) ->take(3) ->values(); } $sections = [ [ 'id' => 'artikel', 'category_slug' => 'artikel', 'title' => 'Artikel', 'items' => $articleNews, ], [ 'id' => 'berita-perusahaan', 'category_slug' => 'berita-perusahaan', 'title' => 'Berita Perusahaan', 'items' => $companyNews, ], ]; if ($activeCategory !== '') { $sections = collect($sections) ->filter(fn ($section) => ($section['category_slug'] ?? '') === $activeCategory) ->values() ->all(); } @endphp

Informasi Terkini Seputaran Kesehatan dan Informasi Resmi Perusahaan Khusus Untuk Anda.

Siap Memulai Perjalanan Fitness Anda ?

@foreach ($sections as $section)

{{ $section['title'] }}

Selengkapnya
@forelse ($section['items'] 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

Konten belum tersedia

Data media untuk kategori ini belum tersedia.

@endforelse
@endforeach
@endsection