1. Go to this page and download the library: Download back1ng/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/ */
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
use Kalnoy\Nestedset\NodeTrait;
use Studio15\FilamentTree\Concerns\InteractsWithTree;
class AwesomeModel extends Model
{
use NodeTrait;
use InteractsWithTree;
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
use Kalnoy\Nestedset\NodeTrait;
use Studio15\FilamentTree\Concerns\InteractsWithTree;
class AwesomeModel extends Model
{
use NodeTrait;
use InteractsWithTree;
return new class extends Migration
{
public function up(): void
{
Schema::table('awesome_model_table', function (Blueprint $table) {
$table->nestedSet();
});
}
public static function getTreeLabelAttribute(): string
{
return 'title';
}
public static function getCreateForm(): array
{
return [
TextInput::make('title')->ic function getEditForm(): array
{
return [
TextInput::make('title')->
public function getTreeCaption(): ?string
{
return $this->description;
}
public static function getInfolistColumns(): array
{
return [
TextEntry::make('description')->label(fn(Category $record, Get $get) => $record->description !== null ? 'Desc' : ''),
IconEntry::make('is_published')->boolean()->label(''),
];
}
public function getScopeAttributes(): array
{
return ['menu_id'];
}
final class AwesomeTree extends TreePage
{
public static function getModel(): string|QueryBuilder
{
return AwesomeModel::scoped(['menu_id' => 2]);
}