You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+38-33Lines changed: 38 additions & 33 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -3,7 +3,8 @@
3
3
[](https://packagist.org/packages/codewithdennis/filament-select-tree)
This package adds a dynamic select tree field to your Laravel / Filament application, allowing you to create interactive hierarchical selection dropdowns based on relationships. It's handy for building selection dropdowns with various customization options.
6
+
This package adds a dynamic select tree field to your Laravel / Filament application, allowing you to create interactive hierarchical selection dropdowns based on relationships. It's handy for
7
+
building selection dropdowns with various customization options.
By default, the type of selection in the tree (single or multiple) is determined by the relationship type: `BelongsTo` for single selection and `BelongsToMany` for multiple selection. If you want to explicitly set the selection type, use:
174
+
By default, the type of selection in the tree (single or multiple) is determined by the relationship type: `BelongsTo` for single selection and `BelongsToMany` for multiple selection. If you want to
175
+
explicitly set the selection type, use:
174
176
175
-
```PHP
176
-
->multiple(false) //or true, Closure that returns boolean
177
+
```php
178
+
->multiple(false)
177
179
```
180
+
178
181
If you need to prepend an item to the tree menu, use the `prepend` method. This method accepts an array or a closure. It is useful when the tree-select is used as a filter (see example below).
179
182
180
183
```php
@@ -192,22 +195,23 @@ use CodeWithDennis\FilamentSelectTree\SelectTree;
192
195
->enableBranchNode()
193
196
->multiple(false)
194
197
->prepend([
195
-
'name'=>'Uncategorized Products', //required
196
-
'value'=>-1, //required
198
+
'name' => 'Uncategorized Products',
199
+
'value' => -1,
197
200
'parent' => null // optional
198
201
'disabled' => false // optional
199
202
'hidden' => false // optional
200
-
'children'=>[] //optional
203
+
'children' => [] //optional
201
204
])
202
205
])
203
206
->query(function (Builder $query, array $data) {
204
207
$categories= [(int) $data['category']];
205
-
return $query->when($data['category'], function ($query, $categories) {
206
-
if($data['category']===-1){
208
+
209
+
return $query->when($data['category'], function (Builder $query, $categories) {
0 commit comments