Custom Page Polymorphic Model Binding

hello, I've created a custom page called "create-content". it refers to Content model which has one-to-one polymorphic relation with several models. I have a public attribute in the page called "contentable" but couldn't find a way to bind models. how can I achieve such thing?

//HospitalResource::table()
        return $table
            ->actions([
                Tables\Actions\Action::make('create-content')
                    ->label('Create Content')
                    ->icon('heroicon-o-plus-circle')
                    ->url(fn(Hospital $record) => route(CreateContent::getRouteName())),
            ]);

//CreateContent page
class CreateContent extends Page implements HasForms
{
    use InteractsWithForms;

    protected static string $view = 'filament.pages.create-content';

    protected static ?string $slug = 'create-content';

    public ?array $data = [];

    public Hospital|Unit|Treatment $contentable;

    public function mount(Hospital|Unit|Treatment $contentable): void
    {
        $this->contentable = $contentable;

        $this->form->fill();
    }
Was this page helpful?