Nested Repeater
Is it possible to have nested repeaters but specify the relationship of the nested one to be on the parent model?
I have three tables: evenement, film, and seance, along with their respective pivot tables and models. I'm following the documentation for integrating with a BelongsToMany relationship from the Filament PHP Repeater Documentation.
Here is my code:
In this setup, the nested repeater evenementSeances defaults to the pivot model (EvenementFilm) instead of the parent model (Evenement). If I uncomment the model specification (->model(Evenement::class)), the relationship does not save correctly.
My goal is for the user to first choose a film, and then, if they want, choose sessions for each selected film. How can I correctly specify the relationship for the nested repeater to be on the parent model?
Regards
3 Replies
Hi everyone,
I've made changes to my database schema. Now, I've introduced events to which I'm attaching films, and I'm indicating that certain screenings of these films are also event screenings.
For this purpose, I now have a table for films, seance, evenement, as well as two pivot tables, evenement_film and evenement_film_seance.
I've also created pivot models EvenementFilm and EvenementFilmSeance following the tutorial "Integrating with a BelongsToMany Eloquent Relationship".
My resource is now configured as follows:
I'm facing another issue: during the first save, the evenement_film_id column in the evenement_film_seance table is null. If I save it again, it adds a new entry with all the information.
My pivot model are :
After triple checking my code, my db and my model, I think this is a Filament bug.
I manage to do a work around with this code (using saveRelationshipsUsing) but I need to implement again update, delete, create.
Sorry for this big message. Do you think I post an issue on filament github ?
I created an issue https://github.com/filamentphp/filament/issues/13069
GitHub
Nesting repeaters for BelongsToMany relationships · Issue #13069 · ...
Package filament/filament Package Version v3.2 Laravel Version v11.9 Livewire Version v3.5 PHP Version PHP 8.3 Problem description Following the example of using a repeater to fill BelongsToMany re...
Thanks