public function folderInfo($folder = '/')
    {
        $folder = $this->cleanFolder($folder);
        $breadCrumbs = $this->breadcrumbs($folder);
        $folderName = $breadCrumbs->pop();

        // Get the names of the sub folders within this folder
        $subFolders = collect($this->disk->directories($folder))->reduce(function ($subFolders, $subFolder) {
            if (!$this->isItemHidden($subFolder)) {
                $subFolders[] = $this->folderDetails($subFolder);
            }

            return $subFolders;
        }, collect([]));

        // Get all files within this folder
        $files = collect($this->disk->files($folder))->reduce(function ($files, $path) {
            if (!$this->isItemHidden($path)) {
                $files[] = $this->fileDetails($path);
            }

            return $files;
        }, collect([]));

        $itemsCount = $subFolders->count() + $files->count();

        return compact('folder', 'folderName', 'breadCrumbs', 'subFolders', 'files', 'itemsCount');
    }
public function folderInfo($folder = '/')
    {
        $folder = $this->cleanFolder($folder);
        $breadCrumbs = $this->breadcrumbs($folder);
        $folderName = $breadCrumbs->pop();

        // Get the names of the sub folders within this folder
        $subFolders = collect($this->disk->directories($folder))->reduce(function ($subFolders, $subFolder) {
            if (!$this->isItemHidden($subFolder)) {
                $subFolders[] = $this->folderDetails($subFolder);
            }

            return $subFolders;
        }, collect([]));

        // Get all files within this folder
        $files = collect($this->disk->files($folder))->reduce(function ($files, $path) {
            if (!$this->isItemHidden($path)) {
                $files[] = $this->fileDetails($path);
            }

            return $files;
        }, collect([]));

        $itemsCount = $subFolders->count() + $files->count();

        return compact('folder', 'folderName', 'breadCrumbs', 'subFolders', 'files', 'itemsCount');
    }
public function folderInfo ( $ folder = '/' ) { $ folder = $ this -> cleanFolder ( $ folder ) ; $ breadCrumbs = $ this -> breadcrumbs ( $ folder ) ; $ folderName = $ breadCrumbs -> pop ( ) ; // Get the names of the sub folders within this folder $ subFolders = collect ( $ this -> disk -> directories ( $ folder ) ) -> reduce ( function ( $ subFolders , $ subFolder ) { if ( ! $ this -> isItemHidden ( $ subFolder ) ) { $ subFolders [ ] = $ this -> folderDetails ( $ subFolder ) ; } return $ subFolders ; } , collect ( [ ] ) ) ; // Get all files within this folder $ files = collect ( $ this -> disk -> files ( $ folder ) ) -> reduce ( function ( $ files , $ path ) { if ( ! $ this -> isItemHidden ( $ path ) ) { $ files [ ] = $ this -> fileDetails ( $ path ) ; } return $ files ; } , collect ( [ ] ) ) ; $ itemsCount = $ subFolders -> count ( ) + $ files -> count ( ) ; return compact ( 'folder' , 'folderName' , 'breadCrumbs' , 'subFolders' , 'files' , 'itemsCount' ) ; }
Return files and directories within a folder.

@param string $folder

@return array of [
'folder' => 'path to current folder',
'folderName' => 'name of just current folder',
'breadCrumbs' => breadcrumb array of [ $path => $foldername ],
'subfolders' => array of [ $path => $foldername] of each subfolder,
'files' => array of file details on each file in folder,
'itemsCount' => a combined count of the files and folders within the current folder
]
Return files and directories within a folder .