Z3d0X / filament-fabricator

Block-Based Page Builder Skeleton for your Filament Apps
https://filamentphp.com/plugins/fabricator
MIT License
269 stars 52 forks source link

How to add multiple page models #121

Closed luckykenlin closed 8 months ago

luckykenlin commented 9 months ago

How to add multiple page models

I've worked out you can add blocks to any Model.

public static function form(Form $form): Form
    {
        return $form
            ->schema([
                TextInput:make('title'),
                Group::make()
                    ->schema([
                        PageBuilder::make('blocks')
                            ->label(__('filament-fabricator::page-resource.labels.blocks'))
                            ->blocks(FilamentFabricator::getPageBlocks()),
                    ])->columnSpan(2),
            ]);
    }

And add a json field called `blocks to your table.

$table->json('blocks')->nullable();

Seems to work fine, so..? 🤷‍♂️

Originally posted by @tobz-nz in https://github.com/Z3d0X/filament-fabricator/discussions/44#discussioncomment-5029838

luckykenlin commented 9 months ago

So, I've implemented this approach, which works great. How can I handle the route since this isn't the original Page Model? Make my own? I prefer not to mix all blogs and regular page like the Contact page, under the same page resource.