ikinci temizlik tamamlandı
This commit is contained in:
@@ -0,0 +1,42 @@
|
||||
<?php
|
||||
/**
|
||||
* @api-readonly
|
||||
* Returns simple list of document folders
|
||||
*/
|
||||
// resources/views/admin-ajax/get-document-folders-simple.blade.php
|
||||
|
||||
$basePath = base_path('storage/documents');
|
||||
|
||||
function scanFolders($path, $relativePath = '') {
|
||||
$items = [];
|
||||
|
||||
if (!is_dir($path)) {
|
||||
return $items;
|
||||
}
|
||||
|
||||
foreach (scandir($path) as $item) {
|
||||
if ($item === '.' || $item === '..') continue;
|
||||
|
||||
$fullPath = $path . DIRECTORY_SEPARATOR . $item;
|
||||
$itemRelativePath = $relativePath ? $relativePath . '/' . $item : $item;
|
||||
|
||||
if (is_dir($fullPath)) {
|
||||
$pdfCount = count(glob($fullPath . '/*.pdf'));
|
||||
|
||||
$items[] = [
|
||||
'text' => $item,
|
||||
'path' => $itemRelativePath,
|
||||
'pdf_count' => $pdfCount,
|
||||
'children' => scanFolders($fullPath, $itemRelativePath)
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
usort($items, fn($a, $b) => strcmp($a['text'], $b['text']));
|
||||
return $items;
|
||||
}
|
||||
|
||||
echo json_encode([
|
||||
'success' => true,
|
||||
'folders' => scanFolders($basePath)
|
||||
]);
|
||||
Reference in New Issue
Block a user