FilamentF
Filament3y ago
giro

Any example of a multilevel category?

If I have a model structure like this.
public function up(): void
    {
        Schema::create('categories', static function (Blueprint $table) {
            $table->id();
            $table->string('name');
            $table->string('slug')->unique();
            $table->text('description')->nullable();
            $table
                ->foreignId('parent_id')
                ->nullable()
                ->constrained('categories')
                ->onDelete('set null');
            $table->timestamps();
        });
    }


Any example how can I manage this with filament (List/Create)?

Thanks.
Solution
So if you are using parents and children, you would then select only the top level with a scope and apply that scope, or apply it to the getTableQuery(). Then you can build a relationship manager for the sub categories.
Was this page helpful?