protected function buildDirectory($directories, $parent)
    {
        $directories = $directories->map(function ($dir) use ($parent) {
            $dir = str_replace($parent . '/', '', $dir);

            return $dir;
        });

        $html = '<ul>';
        $directories->each(function ($dir) use (&$html, $parent) {
            $subParent = $parent . '/' . $dir;
            $url       = request()->url() . '?folder=' . $dir;

            $dir  = str_replace('public/', 'storage/', $dir);
            $html .= "<li>";
            $html .= "<a href='{$url}'>{$dir}</a>";
            if ($child = $this->scanDirectory($subParent)) {
                $html .= $this->buildDirectory($child, $subParent);
            }
            $html .= "</li>";
        });
        $html .= '</ul>';

        return $html;
    }
protected function buildDirectory($directories, $parent)
    {
        $directories = $directories->map(function ($dir) use ($parent) {
            $dir = str_replace($parent . '/', '', $dir);

            return $dir;
        });

        $html = '<ul>';
        $directories->each(function ($dir) use (&$html, $parent) {
            $subParent = $parent . '/' . $dir;
            $url       = request()->url() . '?folder=' . $dir;

            $dir  = str_replace('public/', 'storage/', $dir);
            $html .= "<li>";
            $html .= "<a href='{$url}'>{$dir}</a>";
            if ($child = $this->scanDirectory($subParent)) {
                $html .= $this->buildDirectory($child, $subParent);
            }
            $html .= "</li>";
        });
        $html .= '</ul>';

        return $html;
    }
protected function buildDirectory ( $ directories , $ parent ) { $ directories = $ directories -> map ( function ( $ dir ) use ( $ parent ) { $ dir = str_replace ( $ parent . '/' , '' , $ dir ) ; return $ dir ; } ) ; $ html = '<ul>' ; $ directories -> each ( function ( $ dir ) use ( & $ html , $ parent ) { $ subParent = $ parent . '/' . $ dir ; $ url = request ( ) -> url ( ) . '?folder=' . $ dir ; $ dir = str_replace ( 'public/' , 'storage/' , $ dir ) ; $ html .= "<li>" ; $ html .= "<a href='{$url}'>{$dir}</a>" ; if ( $ child = $ this -> scanDirectory ( $ subParent ) ) { $ html .= $ this -> buildDirectory ( $ child , $ subParent ) ; } $ html .= "</li>" ; } ) ; $ html .= '</ul>' ; return $ html ; }
Build the directory lists.

@param \Illuminate\Support\Collection $directories
@param string $parent
@return string
Build the directory lists .