Skip to content

Commit 8a0cb92

Browse files
Update README.md
1 parent 76807b9 commit 8a0cb92

File tree

1 file changed

+40
-72
lines changed

1 file changed

+40
-72
lines changed

README.md

Lines changed: 40 additions & 72 deletions
Original file line numberDiff line numberDiff line change
@@ -18,100 +18,68 @@ php artisan filament:assets
1818
```
1919

2020
## Features
21-
- ✅ Dark mode
22-
- ✅ Search
23-
-`BelongsTo` support
24-
-`BelongsToMany` support
25-
- ❌ Disabled options (Planned)
26-
21+
22+
- Dark Mode: It seamlessly supports both Filament's light and dark modes out of the box.
23+
- Search: Searching is fully supported, and it seamlessly searches through all levels within the tree structure.
24+
- BelongsTo Integration: Establish connections within your data effortlessly.
25+
- BelongsToMany Integration: Simplify the management of complex relationships through BelongsToMany integration.
26+
27+
🐛 One thing I have noticed about this project is that it tends to run a lot of queries, mainly because of its recursive design. Working to fix this in the upcoming updates.
28+
2729
## Usage
2830

2931
```PHP
32+
// Create a tree based on a 'BelongsToMany' relationship
33+
SelectTree::make('categories')
34+
->relationship('categories', 'name', function ($query) {
35+
return $query;
36+
})
37+
38+
// Create a tree based on a 'BelongsTo' relationship
3039
SelectTree::make('category_id')
40+
->relationship('category', 'name', function ($query) {
41+
return $query;
42+
})
3143

32-
// Create a tree based on a `BelongsToMany` relationship
33-
->relationship('categories', 'name', fn($query) => $query),
44+
// Set a custom placeholder when no items are selected
45+
->placeholder(__('Enter your custom placeholder here'))
3446

35-
// Create a tree based on a `BelongsTo` relationship
36-
->relationship('category', 'name', fn($query) => $query),
37-
38-
// Set a custom placeholder for when no items are selected
39-
->placeholder(__('Your custom placeholder here'))
47+
// Enable the selection of groups
48+
->enableBranchNode()
4049

41-
// Enables the selection of groups.
42-
->enableBranchNode()
43-
44-
// Adjust the emptyLabel for when there are zero search results.
45-
->emptyLabel(__('No results found'))
50+
// Customize the label when there are zero search results
51+
->emptyLabel(__('No results found'))
4652

47-
// Show the count of children alongside the group's name.
48-
->withCount()
53+
// Display the count of children alongside the group's name
54+
->withCount()
4955

50-
// To keep the dropdown open at all times
51-
->alwaysOpen()
56+
// Keep the dropdown open at all times
57+
->alwaysOpen()
5258

53-
// By default, all nodes are independent.
54-
->independent(false)
55-
56-
// When 'independent' is set to false, the tree will open with the selected values by default.
57-
->expandSelected(false)
58-
59-
// Display individual leaf nodes instead of the main group when all leaf nodes are selected.
60-
->grouped(false)
59+
// Set nodes as dependent
60+
->independent(false)
6161

62-
// By default, the clearable icon is enabled, but you can hide it with:
63-
->clearable(false)
62+
// Expand the tree with selected values by default
63+
->expandSelected(false)
6464

65-
// Enable the option to save multiple values as a string (comma-separated)
66-
->multiple()
65+
// Display individual leaf nodes instead of the main group when all leaf nodes are selected
66+
->grouped(false)
6767

68-
// Activates the search functionality for the SelectTree.
69-
->searchable()
70-
```
71-
### Relationships (examples)
68+
// Hide the clearable icon
69+
->clearable(false)
7270

73-
```PHP
74-
public function category(): BelongsTo
75-
{
76-
return $this->belongsTo(Category::class);
77-
}
78-
```
79-
```PHP
80-
public function categories(): belongsToMany
81-
{
82-
return $this->belongsToMany(Category::class);
83-
}
84-
```
85-
### Custom
86-
If you prefer to create custom options rather than utilizing a pre-existing model, you can achieve this using the following example:
71+
// Enable the option to save multiple values as a string (comma-separated)
72+
->multiple()
8773

88-
```PHP
89-
->options([
90-
[
91-
'name' => 'Electronics',
92-
'value' => 'electronics',
93-
'children' => [
94-
[
95-
'name' => 'Mobile Devices',
96-
'value' => 'mobile devices',
97-
'children' => [
98-
[
99-
'name' => 'Apple Products',
100-
'value' => 'apple products',
101-
]
102-
]
103-
]
104-
]
105-
],
106-
])
74+
// Activate the search functionality for the SelectTree
75+
->searchable();
10776
```
10877

10978
## Screenshots
11079

11180
<img width="641" alt="light" src="https://github.com/CodeWithDennis/filament-select-tree/assets/23448484/4d348c85-5ee9-45b1-9424-0d8b3efcc02e">
11281
<img width="649" alt="dark" src="https://github.com/CodeWithDennis/filament-select-tree/assets/23448484/396627ff-bf36-44b7-b20c-0d32b2eff957">
11382

114-
11583
## Changelog
11684
Please see [CHANGELOG](CHANGELOG.md) for more information on what has changed recently.
11785

0 commit comments

Comments
 (0)