Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Polymorphic relation form #5647

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

NikolayMurha
Copy link
Contributor

Add polymorphic relation field support.

Usage example:

$form->radioButton('menuable_type', __('Link to'))->options([
    (new PageCategory())->getMorphClass() => __('Page Category'),
    (new Page())->getMorphClass() => __('Page'),
    (new Category())->getMorphClass() => __('Product Category'),
    (new Product())->getMorphClass() => __('Product'),
])->when((new PageCategory())->getMorphClass(), function (Form $form) {
    $form->morphTo('menuable', PageCategories::class, "Menu Object");
})->when((new Page())->getMorphClass(), function (Form $form) {
    $form->morphTo('menuable', Pages::class, "Menu Object");
})->when((new Category())->getMorphClass(), function (Form $form) {
    $form->morphTo('menuable', Categories::class, "Menu Object");
})->when((new Product())->getMorphClass(), function (Form $form) {
    $form->morphTo('menuable', Products::class, "Menu Object");
});

@NikolayMurha NikolayMurha force-pushed the polimorphyc_relation_form branch 2 times, most recently from 6a663cf to 8015ed7 Compare August 30, 2022 18:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant