Saving relationships when creating record with Repeater
I have an already working application with Filament v2, Laravel 9, PHP 8.0.
There's a Model called Menu. A Menu could be available on a given week, so when you create a Menu you have to assign Offers to it, and also Meals to the Offers, which is set on the Dish Model with the price and an active toggle.
So that's
This was already working well with 7 weekdays, but now there's a request to make it work with any amount of days, even like only weekends.
Let me show you the essential parts of the code.
I know the
How can I tell the
I tried to solve this with
There's a Model called Menu. A Menu could be available on a given week, so when you create a Menu you have to assign Offers to it, and also Meals to the Offers, which is set on the Dish Model with the price and an active toggle.
So that's
Menu hasMany Offer, Offer hasMany Dish, Dish belongsToMany Meal. This was already working well with 7 weekdays, but now there's a request to make it work with any amount of days, even like only weekends.
Let me show you the essential parts of the code.
I know the
Repeater could be used like... Add an item, then choose which day, than add another if wanted, but we want to keep these 7 items fixed, it works better UX wise.How can I tell the
Repeater somehow, that it should only save the Offer when that meal_id on the Grid::relationship('dish') exists?I tried to solve this with
->saveRelationshipsUsing(), but no luck so far.