1. Go to this page and download the library: Download alareqi/filament-tree library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
use Alareqi\FilamentTree\Concerns\InteractsWithTreeTable;
use Filament\Resources\Pages\ListRecords;
class ListCategories extends ListRecords
{
use InteractsWithTreeTable;
}
use Alareqi\FilamentTree\Columns\TreeColumn;
use Filament\Tables\Columns\TextColumn;
use Filament\Tables\Table;
public static function table(Table $table): Table
{
return $table
->columns([
TreeColumn::make('name')->searchable(),
TextColumn::make('updated_at')->dateTime()->sortable(),
])
->reorderable('sort_order')
->tree(
parentColumn: 'parent_id',
treeColumn: 'name',
);
}