From a80f5d72eeb9bac09f2a89cc5a1d52cd4c6843d1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn?= Date: Sat, 23 Jan 2021 08:54:34 +0100 Subject: [PATCH] adding --- app/FileManager.php | 27 ++++++++++++++++--- .../components/filemanager/filemanager.riot | 3 ++- 2 files changed, 26 insertions(+), 4 deletions(-) diff --git a/app/FileManager.php b/app/FileManager.php index 667fb8b..c1be3b6 100644 --- a/app/FileManager.php +++ b/app/FileManager.php @@ -21,10 +21,14 @@ class FileManager { $results = []; + $directories = []; + + $files = []; + // getting files from directory - $files = scandir($path); + $items = scandir($path); - foreach($files as $file) { + foreach($items as $file) { // ignore parent directories if ($file === '.' || $file === '..') { @@ -44,9 +48,26 @@ class FileManager if ($result['is_file']) { $result['size'] = $this->formatBytes($meta['size']); + $files[] = $result; + } else { + $directories[] = $result; } + } - $results[] = $result; + usort($directories, function($a, $b) { + if (strtolower($a['filename']) < strtolower($b['filename'])) { + return 0; + } else { + return 1; + } + }); + + foreach($directories as $directory) { + $results[] = $directory; + } + + foreach($files as $file) { + $results[] = $file; } return $results; diff --git a/resources/js/components/filemanager/filemanager.riot b/resources/js/components/filemanager/filemanager.riot index adf2075..45a6e92 100644 --- a/resources/js/components/filemanager/filemanager.riot +++ b/resources/js/components/filemanager/filemanager.riot @@ -72,7 +72,8 @@ /** * - * + * + * */ files() { axios.get('/api/file/' + this.props.id, {