File tree Expand file tree Collapse file tree 2 files changed +11
-2
lines changed Expand file tree Collapse file tree 2 files changed +11
-2
lines changed Original file line number Diff line number Diff line change 99use Illuminate \Support \Str ;
1010use Kalnoy \Nestedset \NestedSet ;
1111use Kalnoy \Nestedset \QueryBuilder ;
12+ use RuntimeException ;
1213
1314/**
1415 * Parent select builder
@@ -22,9 +23,14 @@ public static function make(QueryBuilder $query): Select
2223 $ query ->getModel ()::class::getTreeLabelAttribute (),
2324 );
2425
26+ $ depth = $ item ->getAttribute ('depth ' );
27+ if ($ depth < 1 ) {
28+ throw new RuntimeException ('The tree is corrupted, please Fix tree ' );
29+ }
30+
2531 $ prefix = Str::repeat (
2632 string: '-- ' ,
27- times: $ item -> getAttribute ( ' depth ' ) ,
33+ times: $ depth ,
2834 );
2935
3036 return trim ("{$ prefix } {$ title }" );
Original file line number Diff line number Diff line change 1616use Illuminate \Contracts \View \View ;
1717use Illuminate \Database \Eloquent \Model ;
1818use Kalnoy \Nestedset \NestedSet ;
19+ use Kalnoy \Nestedset \QueryBuilder ;
1920use Livewire \Attributes \Computed ;
2021use Livewire \Attributes \On ;
2122use Livewire \Attributes \Session ;
@@ -72,9 +73,11 @@ public function editAction(): EditAction
7273 $ form = $ this ->component ::getEditForm ();
7374
7475 if (config ('filament-tree.show-parent-select-while-edit ' )) {
76+ $ model = $ this ->component ::getModel ();
77+
7578 array_unshift (
7679 $ form ,
77- ParentSelect::make ($ this -> component :: getModel ()),
80+ ParentSelect::make ($ model instanceof QueryBuilder ? $ model : $ model :: query ()),
7881 );
7982 }
8083
You can’t perform that action at this time.
0 commit comments