Subversion-Projekte lars-tiefland.laravel_shop

Revision

Revision 1657 | Ganze Datei anzeigen | Leerzeichen ignorieren | Details | Blame | Letzte Änderung | Log anzeigen | RSS feed

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