Z3d0X / filament-fabricator

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

How to add to multiple models? #27

Closed tobz-nz closed 1 year ago

tobz-nz commented 1 year ago

Sorry Discussions are disabled so asking this question here instead.

I can't figure out how to add fabricator to my other models - is it fixed to only the provided Pages model? I really want to use it on a number of different models - is this possible?

Z3d0X commented 1 year ago

https://github.com/Z3d0X/filament-fabricator/issues/26#issuecomment-1321486762

tobz-nz commented 1 year ago

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..? 🤷‍♂️

Z3d0X commented 1 year ago

Awesome, that works for you! I originally had a different idea than this. Thanks for sharing your idea