cube-agency / filament-tree-view
Filament package to view records in tree view
Requires
- php: ^8.2
- filament/filament: ^3.0
- illuminate/contracts: ^10.0|^11.0
- kalnoy/nestedset: ^6.0
- spatie/laravel-package-tools: ^1.15.0
Requires (Dev)
- laravel/pint: ^1.0
- nunomaduro/collision: ^7.10|^8.1
- nunomaduro/larastan: ^2.0.1
- orchestra/testbench: ^8.0|^9.0
- pestphp/pest: ^2.0
- pestphp/pest-plugin-arch: ^2.0
- pestphp/pest-plugin-laravel: ^2.0
- phpstan/extension-installer: ^1.1
- phpstan/phpstan-deprecation-rules: ^1.0
- phpstan/phpstan-phpunit: ^1.0
This package is auto-updated.
Last update: 2024-11-29 14:42:42 UTC
README
Filament plugin for showing records in tree view.
Installation
You can install the package via composer:
composer require cube-agency/filament-tree-view
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.