@php $categories = \App\Models\Backend\Ref::where('cat', 'DOWNLOAD_CAT')->orderBy('sort')->pluck('descr', 'code'); $type = request()->query('type', ''); $search = trim((string) request()->query('search_keyword', '')); $selectedCategory = null; foreach ($categories as $code => $name) { if ($type !== '' && ($type === \Illuminate\Support\Str::slug($code) || $type === \Illuminate\Support\Str::slug($name))) { $selectedCategory = $code; break; } } $downloadsQuery = \App\Models\Backend\ContentDownload::published() ->where('download_language', $lang) ->when($selectedCategory, fn ($query) => $query->where('download_category', $selectedCategory)) ->when($search !== '', fn ($query) => $query->where(function ($query) use ($search) { $query->where('download_title', 'like', "%{$search}%") ->orWhere('download_source', 'like', "%{$search}%"); })) ->orderBy('download_sorting') ->orderByDesc('download_date') ->orderBy('download_title'); $downloads = $downloadsQuery->paginate(12)->withQueryString(); $pageTitle = $selectedCategory ? ($categories[$selectedCategory] ?? $selectedCategory) : 'Dokumen & Sumber'; @endphp
Pusat Sumber

{{ $pageTitle }}

Terokai dan baca koleksi dokumen serta penerbitan kami secara dalam talian.

@if($categories->isNotEmpty())
Semua @foreach($categories as $code => $name) @php $categorySlug = \Illuminate\Support\Str::slug($code); @endphp {{ $name }} @endforeach
@endif
@if($downloads->isNotEmpty())
{{ $downloads->total() }} dokumen @if($search !== '')Hasil carian untuk “{{ $search }}”@endif
@foreach($downloads as $item) @php $isPdf = $item->download_file && strtolower(pathinfo($item->download_file, PATHINFO_EXTENSION)) === 'pdf'; $readerUrl = $isPdf ? route('documents.reader.show', $item->download_id) : null; $fileUrl = $item->download_file ? image_url($item->download_file) : null; $openUrl = $readerUrl ?? $fileUrl ?? '#'; $categoryName = $categories[$item->download_category] ?? $item->download_category; @endphp @endforeach
@if($downloads->hasPages()) @endif @else

Tiada dokumen ditemui

Cuba kata kunci lain atau pilih kategori yang berbeza.

@endif