public function listFiles($directory)
    {
        if (!file_exists($directory)) {
            return collect([]);
        }

        return $this->scanDir($directory)->reject(function ($item) {
            return !$this->isAllowedDirectory($item) && !$this->isYamlFile($item);
        })->mapWithKeys(function ($item) {
            if (is_dir($item)) {
                return [basename($item) => $this->listFiles($item)->toArray()];
            }

            return [$this->cleanKey($item) => $item];
        });
    }
public function listFiles($directory)
    {
        if (!file_exists($directory)) {
            return collect([]);
        }

        return $this->scanDir($directory)->reject(function ($item) {
            return !$this->isAllowedDirectory($item) && !$this->isYamlFile($item);
        })->mapWithKeys(function ($item) {
            if (is_dir($item)) {
                return [basename($item) => $this->listFiles($item)->toArray()];
            }

            return [$this->cleanKey($item) => $item];
        });
    }
public function listFiles ( $ directory ) { if ( ! file_exists ( $ directory ) ) { return collect ( [ ] ) ; } return $ this -> scanDir ( $ directory ) -> reject ( function ( $ item ) { return ! $ this -> isAllowedDirectory ( $ item ) && ! $ this -> isYamlFile ( $ item ) ; } ) -> mapWithKeys ( function ( $ item ) { if ( is_dir ( $ item ) ) { return [ basename ( $ item ) => $ this -> listFiles ( $ item ) -> toArray ( ) ] ; } return [ $ this -> cleanKey ( $ item ) => $ item ] ; } ) ; }
Get all files from dir.

@param $directory

@return \Illuminate\Support\Collection
Get all files from dir .