Storing repeater data in a pivot table
Hi ,ho to save data from repeater into pivot table?
Here's the Models and the table I have.
----
Tables:
expert :id, first_name,last_name,...
diplome :id name,...
diplome_experts : id,diplome_id,expert_id,year,...
Expert Model :
Expert (Livewire)
Error captured :
SQLSTATE[42S22]: Column not found: 1054 Unknown column 'diplome_id' in 'field list' (Connection: mysql, SQL: insert into
**diplomes**
(diplome_id
, year
, specialite_id
, etablissement_id
, updated_at
, created_at
)
------------
The data going to be stored in the 'diplome' table and not in the 'diplome_ experts' pivot table?
Any help , Thanks5 Replies
you need to define a pivot model, and then a hasMany() relationship to that pivot model. you can use that hasmany as the repeater
because then you are creating records in the pivot table, not the related table
Thank you ! Your support means the world
The pivot Model
The Expert Model with hasMany() relationship
Expert Ressource
God bless you
This isn't working for me and I'm puzzled by why that is. I've seen a few other questions where the solution is the same, but whatever I do, nothing is showing up when I have saved the repeater data (or entered manually to test it). Also, saving doesn't automatically write the edit record id to the DB (as pictured in Amitav Roy's vid: https://www.youtube.com/watch?v=DKt7v_QSt18). I must be missing something, but what? 🧐
Amitav Roy
YouTube
14 Mastering Laravel Filament: Building a Repeater with Relationship
Are you looking to take your Laravel Filament skills to the next level? In this tutorial, we'll walk you through the process of building a repeater with a relationship using Laravel Filament. With the help of our expert instructors, you'll learn how to leverage the power of Laravel Filament to create powerful, dynamic interfaces for your web app...
please send the code
also are you using this outside the admin panel?
its probably best if you add all the details in a new theead
Hey! No, using it in admin panel
@danharrin Sooo, I think I found the issue. My pivot table didn't have an ID on it. Adding that resolved it 🤦♂️