@php $storagePath = storage_path('app/public'); $folders = []; $selectedFolder = request('folder', ''); $folderContents = []; if (is_dir($storagePath)) { $items = scandir($storagePath); foreach ($items as $item) { if ($item !== '.' && $item !== '..' && is_dir($storagePath . '/' . $item)) { $folders[$item] = ucfirst(str_replace(['-', '_'], ' ', $item)); } } } // Get contents of selected folder if ($selectedFolder && is_dir($storagePath . '/' . $selectedFolder)) { $contents = scandir($storagePath . '/' . $selectedFolder); foreach ($contents as $item) { if ($item !== '.' && $item !== '..') { $itemPath = $storagePath . '/' . $selectedFolder . '/' . $item; $folderContents[] = [ 'name' => $item, 'path' => $itemPath, 'is_dir' => is_dir($itemPath), 'size' => is_file($itemPath) ? filesize($itemPath) : 0, 'modified' => filemtime($itemPath), ]; } } } @endphp @if (count($folders) > 0) @foreach ($folders as $folder => $folderName)