@extends('frontend.layouts.app') @php use App\Helpers\Helper; $isEn = app()->getLocale() == 'en'; $pick = fn($m) => $isEn ? $m->name_en : $m->name_np ?? $m->name_en; // icon + colour per file extension $types = [ 'pdf' => ['fa-file-pdf', 'text-red-600 bg-red-50'], 'doc' => ['fa-file-word', 'text-blue-600 bg-blue-50'], 'docx' => ['fa-file-word', 'text-blue-600 bg-blue-50'], 'xls' => ['fa-file-excel', 'text-green-600 bg-green-50'], 'xlsx' => ['fa-file-excel', 'text-green-600 bg-green-50'], 'csv' => ['fa-file-excel', 'text-green-600 bg-green-50'], 'ppt' => ['fa-file-powerpoint', 'text-orange-600 bg-orange-50'], 'pptx' => ['fa-file-powerpoint', 'text-orange-600 bg-orange-50'], 'jpg' => ['fa-file-image', 'text-purple-600 bg-purple-50'], 'jpeg' => ['fa-file-image', 'text-purple-600 bg-purple-50'], 'png' => ['fa-file-image', 'text-purple-600 bg-purple-50'], 'zip' => ['fa-file-zipper', 'text-yellow-600 bg-yellow-50'], 'rar' => ['fa-file-zipper', 'text-yellow-600 bg-yellow-50'], ]; $fileSize = function ($path) { $full = public_path($path); if (!$path || !is_file($full)) { return null; } $b = filesize($full); return $b >= 1048576 ? round($b / 1048576, 1) . ' MB' : max(1, round($b / 1024)) . ' KB'; }; $total = $downloadCategories->sum(fn($c) => $c->downloads->count()); @endphp @section('title', 'Downloads') @section('content') {{-- Hero Section --}} @include('frontend.partials.hero', [ 'mainHeading' => Helper::contentText('pages.download'), 'subHeading' => Helper::contentText('pages.download_tagline'), 'breadcrumb1' => [ 'name' => __('route.home'), 'route' => route('home'), ], 'breadcrumb2' => [ 'name' => __('route.download'), 'route' => route('downloads'), 'class' => 'text-gray-400', ], 'breadcrumb3' => null, 'breadcrumb4' => null, ])
@if ($total > 0)
{{-- Categories --}} {{-- Files --}}
@foreach ($downloadCategories as $category) @continue($category->downloads->isEmpty())

{{ $pick($category) }} {{ $category->downloads->count() }}

    @foreach ($category->downloads as $download) @php $ext = strtolower(pathinfo($download->file, PATHINFO_EXTENSION)); [$icon, $tone] = $types[$ext] ?? ['fa-file-lines', 'text-gray-600 bg-gray-100']; $name = $pick($download); $size = $fileSize($download->file); @endphp
  • {{ $name }}

    {{ $ext ?: 'file' }}@if ($size) · {{ $size }} @endif

  • @endforeach
@endforeach {{-- nothing matches the search --}}

{{ $isEn ? 'No files match your search.' : 'तपाईंको खोजसँग मेल खाने फाइल भेटिएन।' }}

@else

{!! Helper::content('pages.no_download') !!}

@endif
@endsection