@php $categories = DB::table('resourcecategories')->get(); if (!function_exists('formatBytes')) { function formatBytes($bytes, $precision = 2) { $units = ['B', 'KB', 'MB', 'GB', 'TB']; $bytes = max($bytes, 0); $pow = floor(($bytes ? log($bytes) : 0) / log(1024)); $pow = min($pow, count($units) - 1); $bytes /= pow(1024, $pow); return round($bytes, $precision) . ' ' . $units[$pow]; } } @endphp @foreach ($categories as $index => $category) @php $categoryId = 'cat-' . $category->id; $showClass = ($index === 0) ? 'show' : ''; $expandIcon = ($index === 0) ? 'fa-chevron-up' : 'fa-chevron-down'; @endphp

{{ $category->categoryname }}

@php $resources = DB::table('resources') ->where('category', $category->id) ->orderBy('id', 'desc') ->paginate(10, ['*'], 'page_' . $category->id); @endphp @if($resources->count() > 0) @foreach ($resources as $resource) @php $filePath = public_path('uploads/resources/' . $resource->file); $fileExists = file_exists($filePath); $fileSize = $fileExists ? formatBytes(filesize($filePath)) : 'File not found'; @endphp @endforeach
# Filename Size Action
{{ $resource->id }} {{ $resource->filename }} {{ $fileSize }} @if($fileExists) Download @else Not Available @endif
{{ $resources->appends(request()->except('page_' . $category->id))->links() }}
@else

No resources available in this category yet.

@endif
@endforeach