@@ -75,6 +75,8 @@ class SelectTree extends Field implements HasAffixActions
75
75
76
76
protected ?Closure $ createOptionUsing = null ;
77
77
78
+ protected Closure |bool |null $ withTrashed = false ;
79
+
78
80
protected function setUp (): void
79
81
{
80
82
// Load the state from relationships using a callback function.
@@ -133,8 +135,8 @@ private function buildTree(): Collection
133
135
}
134
136
135
137
// Fetch results for both queries
136
- $ nullParentResults = $ nullParentQuery ->get ();
137
- $ nonNullParentResults = $ nonNullParentQuery ->get ();
138
+ $ nullParentResults = $ nullParentQuery ->withTrashed ( $ this -> withTrashed )-> get ();
139
+ $ nonNullParentResults = $ nonNullParentQuery ->withTrashed ( $ this -> withTrashed )-> get ();
138
140
139
141
// Combine the results from both queries
140
142
$ combinedResults = $ nullParentResults ->concat ($ nonNullParentResults );
@@ -230,6 +232,13 @@ public function withCount(bool $withCount = true): static
230
232
return $ this ;
231
233
}
232
234
235
+ public function withTrashed (bool $ withTrashed = true ): static
236
+ {
237
+ $ this ->withTrashed = $ withTrashed ;
238
+
239
+ return $ this ;
240
+ }
241
+
233
242
public function direction (string $ direction ): static
234
243
{
235
244
$ this ->direction = $ direction ;
@@ -356,6 +365,11 @@ public function getGrouped(): bool
356
365
return $ this ->evaluate ($ this ->grouped );
357
366
}
358
367
368
+ public function getWithTrashed (): bool
369
+ {
370
+ return $ this ->evaluate ($ this ->withTrashed );
371
+ }
372
+
359
373
public function getIndependent (): bool
360
374
{
361
375
return $ this ->evaluate ($ this ->independent );
0 commit comments