- How do I integrate Filament Tree with an existing Filament Resource for managing categories?
- First, apply the `ModelTree` trait to your Eloquent model and add `parent_id` and `order` columns to your database table. Then, use the Artisan command `php artisan make:filament-tree-resource CategoryResource` to generate a Resource with built-in tree functionality. The plugin automatically handles drag-and-drop sorting and nesting.
- Does Filament Tree support Filament v4, or should I upgrade to v5 for full features?
- Filament Tree supports Filament v4 (via v3.x plugin) but lacks toolbar actions and some v5 features. The package explicitly states it will only update to v4.x, so if you need advanced features like translations or toolbar actions, upgrading to Filament v5+ is recommended. Check the compatibility table in the README for details.
- What database schema changes are required to use Filament Tree?
- You need to add `parent_id` (default `-1`) and `order` columns to your table, both indexed for performance. Use this migration snippet: `Schema::table('categories', function (Blueprint $table) { $table->integer('parent_id')->default(-1)->index(); $table->integer('order')->default(0); });`. The plugin assumes these columns by default but allows customization via `determineParentColumnName()`.
- Can I customize the tree UI, like adding custom icons or actions for nodes?
- Yes, Filament Tree supports full customization. Override methods like `getTreeRecordTitle()`, `getTreeRecordIcon()`, or `getTreeRecordActions()` in your Resource/Widget. You can also extend the default styling by publishing the config and modifying the Tailwind CSS or jQuery Nestable assets. Check the README for available hooks and overrides.
- Will Filament Tree work with deeply nested data (e.g., 6+ levels deep)?
- While Filament Tree supports unlimited depth theoretically, performance may degrade with very deep structures (e.g., >5 levels). To optimize, use the `$maxDepth` setting to limit nesting or pre-collapse nodes. Ensure your `parent_id` column is indexed, and consider caching tree queries for read-heavy applications. Test with your expected dataset size.
- How do I create a tree widget or page for Filament Tree?
- Use the Artisan generators: `php artisan make:filament-tree-widget CategoryWidget --model=Category` for a widget, or `php artisan make:filament-tree-page CategoryTree --resource=Category` for a page. These commands scaffold the necessary components with drag-and-drop functionality. Customize the generated class by overriding methods like `getTreeQuery()` or `configureTree()`.
- Is Filament Tree compatible with Laravel 10 and the latest Filament versions?
- Yes, Filament Tree is designed for Laravel 10+ and Filament v5+. The package explicitly drops support for older versions (e.g., Filament v3), so ensure your stack aligns with these requirements. Check the compatibility table in the README for version-specific details. Always test in a staging environment before production deployment.
- What alternatives exist if I need a more scalable tree solution for large datasets?
- For heavy-load menus or complex trees, consider `filament-nestable-tree` by the same authors, which is optimized for performance. Alternatively, evaluate standalone libraries like `spatie/laravel-nestedset` or `ocramius/proxy-manager` for custom tree implementations. Filament Tree is ideal for mid-sized hierarchies (e.g., menus, categories) but may require optimizations for datasets exceeding 10,000 nodes.
- How do I handle translations for tree nodes in Filament Tree?
- Filament Tree integrates with Spatie’s `translatable` package for multilingual support. Ensure your model uses the `HasTranslations` trait and configure the `translatable` columns. Override the `getTreeRecordTitle()` method to return translated values, e.g., `return $record->translate('name')->title;`. The plugin automatically respects Filament’s locale settings.
- Are there any known issues with Filament Tree in production environments?
- Common production concerns include frontend asset conflicts (jQuery/Tailwind) and performance with large trees. Ensure your `tailwind.config.js` includes the plugin’s CSS imports and that jQuery is properly loaded. For deep trees, monitor memory usage and consider lazy-loading nodes. The package is MIT-licensed with active development, but official support is limited to GitHub issues—test thoroughly before deployment.