Weave Code
Code Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message
Filament Select Tree

Filament Select Tree Laravel Package

codewithdennis/filament-select-tree

Dynamic select tree field for Laravel Filament that renders hierarchical dropdowns from relationships or custom queries. Supports BelongsTo and BelongsToMany, parent/child attributes, and customizable parent/child query scopes with optional strict root behavior.

View on GitHub
Deep Wiki
Context7

The multi-level select field lets you pick one or multiple options from a list that is neatly organized into different levels.

Frequently asked questions about Filament Select Tree
How do I install and set up filament-select-tree in a Laravel Filament 4.x project?
Run `composer require codewithdennis/filament-select-tree:4.x` and execute `php artisan filament:assets` to compile assets. The package is designed for Filament 4.x (use the 3.x branch for Filament 3.x). No database migrations are required—just configure the field in your Filament form or table.
Can I use this package for a BelongsToMany relationship, like assigning multiple categories to a post?
Yes, the package supports BelongsToMany relationships out of the box. Use `SelectTree::make('categories')->relationship('categories', 'name', 'parent_id')` to enable multi-select functionality. The tree will render as a hierarchical dropdown where users can select multiple nodes.
What Laravel and Filament versions does this package support?
The package is compatible with Laravel 10/11 and Filament 3.x/4.x. For Filament 3.x, use the `3.x` branch of the package. PHP 8.5+ is required. Always check the [GitHub repo](https://github.com/CodeWithDennis/filament-select-tree) for the latest version compatibility.
How do I customize the tree query for non-standard parent-child relationships (e.g., using a custom attribute like `parent_code`)?
Use the `modifyQueryUsing` or `modifyChildQueryUsing` methods to customize the query. For example, `SelectTree::make('departments')->relationship('departments', 'name', 'parent_code')` will use `parent_code` instead of `parent_id`. You can also pass a closure to further refine the query logic.
Does the package support soft-deleted models (e.g., withTrashed())? If so, how do I handle orphaned nodes?
Yes, the package supports soft-deleted models. Use `withTrashed()` in your query to include deleted nodes. Orphaned nodes (nodes without a parent) will appear as root-level items. For strict behavior, use `strictNullParentRootNodes()` to prevent promoting orphaned nodes to the root.
Will this package work with large hierarchies (e.g., 5,000+ nodes)? Are there performance considerations?
For large hierarchies, performance depends on your server and client-side rendering. The package loads the entire tree structure at once, which may impact performance. Test with realistic datasets and consider optimizing queries (e.g., `select()` only needed columns) or implementing lazy-loading via custom JavaScript.
Can I use this package for non-Eloquent data, like API responses or in-memory arrays?
Yes, the package supports custom queries via the `query()` method. Pass an array or use a closure to return data in the format `[{ id, name, parent_id }, ...]`. This makes it flexible for non-database hierarchies, such as API responses or dynamically generated trees.
How do I implement a tree filter in a Filament table column (e.g., to filter posts by category)?
Use the `SelectTree::make()` field in a Filament table column filter. Configure it with the same relationship or query as your form field. For example, `SelectTree::make('category_id')->relationship('category', 'name', 'parent_id')` will create a hierarchical filter dropdown in your table.
What happens if I update Filament to a new major version? Will this package break?
The package is tightly coupled to Filament’s internals, so major Filament updates may require updates to this package. Monitor Filament’s upgrade guide and check the package’s [GitHub issues](https://github.com/CodeWithDennis/filament-select-tree/issues) for compatibility announcements. If needed, fork or patch the package for critical fixes.
Are there alternatives to this package for hierarchical selects in Filament? When would I choose another solution?
Alternatives include custom Vue.js components (e.g., using `vue-treeselect`) or simpler nested select fields. Choose this package if you need deep integration with Filament’s form/table system, Eloquent relationship support, and built-in customization (e.g., strict root nodes, query scopes). Opt for a custom solution if you require advanced client-side features (e.g., drag-and-drop) or minimal dependency risk.
Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
terminal42/code-quality-tools
codifyo/ts-generator-bundle
andydefer/laravel-cluster
testo/fiber
mintobit/jobqueue
a4sex/maintenance-bundle
a4sex/entity-date-update
a4sex/client-identifier
a4sex/base-utilites
a4sex/key-value-storage
a4sex/micro-status
chilldev/dependency-injection-extra
datinglibre/datinglibre-app-api
biberltd/corebundle
bricre/symfony-bundle-test
biberltd/logbundle
dominium/http-adapter-bundle
dominium/google-analytics
a4sex/auto-clean-entity
christhompsontldr/laravel-inky