cube-agency/filament-tree-view
Tree View for Filament
Filament plugin for showing records in Tree view.
Compatibility
| Package Version | Filament Version |
|---|---|
| 1.x | 3.x |
| 2.x | 4.x |
| 3.x | 4.x, 5.x |
Installation
You can install the package via composer:
composer require cube-agency/filament-tree-view
Configuration
You can publish the config file with:
php artisan vendor:publish --tag="filament-tree-view-config"
Available Configuration Options
- max_depth: Controls the maximum nesting level of the tree view.
- compact: When set to true, the tree view will be displayed in a compact format. This is useful for displaying large trees with many nodes.
- has_permissions: When set to true, actions will check user permissions before allowing them. If set to false, actions will be available to all users.
- has_user_only_policy: When set to true, resource-specific permissions are ignored and only user permissions are checked improving performance.
Usage
This package uses NestedSet, you should setup your Model/table according to the readme.
Then add trait to your model
<?php
namespace App\Models;
use CubeAgency\FilamentTreeView\Traits\HasTreeView;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Kalnoy\Nestedset\NodeTrait;
class ForumCategory extends Model
{
use HasTreeView;
}
After that you just need to extend ListRecords and CreateRecord pages to use TreeViewRecords and CreateTreeViewRecord respectively
namespace App\Filament\Resources\ForumCategoryResource\Pages;
use App\Filament\Resources\ForumCategoryResource;
use CubeAgency\FilamentTreeView\Resources\Pages\TreeViewRecords;
class ListForumCategories extends TreeViewRecords
{
protected static string $resource = ForumCategoryResource::class;
}
After that you just need to extend CreateRecord resource to use CreateTreeViewRecord
namespace App\Filament\Resources\ForumCategoryResource\Pages;
use App\Filament\Resources\ForumCategoryResource;
use CubeAgency\FilamentTreeView\Resources\Pages\CreateTreeViewRecord;
class CreateForumCategory extends CreateTreeViewRecord
{
protected static string $resource = ForumCategoryResource::class;
}
and that's it, you are ready to go.
Testing
composer test
Changelog
Please see CHANGELOG for more information on what has changed recently.
Contributing
Please see CONTRIBUTING for details.
Security Vulnerabilities
Please review our security policy on how to report security vulnerabilities.
Credits
License
The MIT License (MIT). Please see License File for more information.
Related Packages
Filament plugin for ordering resources stored using the nested set model
A nestable drag-and-drop tree component for Filament v4 and v5. Supports Eloquen...
Filament nestedset tree builder powered by kalnoy/nestedset with Filament v4 and...
A filament package to manage relationships that use the NestedSet model.