@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
Data media untuk kategori ini belum tersedia.