Subversion-Projekte lars-tiefland.laravel_shop

Revision

Revision 1657 | Details | Vergleich mit vorheriger | Letzte Änderung | Log anzeigen | RSS feed

Revision Autor Zeilennr. Zeile
1657 lars 1
<?php
2
 
3
    use App\Models\Directory;
1659 lars 4
    use Illuminate\Database\Eloquent\ModelNotFoundException;
1657 lars 5
    use Illuminate\Support\Collection;
6
 
7
    function getPath( $root, $return_locked_folders = false ): Collection
8
    {
9
        $ini = $GLOBALS["INI"];
10
        $treeRoot = -1;
11
        if ( $ini["treeRoot"] )
12
        {
13
            $treeRoot = $ini["treeRoot"];
14
        }
15
 
16
        $path = collect();
17
        $father = $root;
18
        while ( $father != $treeRoot && !is_null( $father ) )
19
        {
1659 lars 20
            try
21
            {
22
                $row = Directory::where( "id", $father )->whereIn( "status", [ 0, 2 ] )->firstOrFail();
23
            }
24
            catch ( ModelNotFoundException)
25
            {
26
                return $path;
27
            }
1657 lars 28
            $father = $row->directory_id;
29
            $path[] = $row;
30
        }
1659 lars 31
        return $path;
1657 lars 32
    }
33