Recently I discovered a feature of eloquent
called sync
, vi that it sort of compares the data passed with the data that is in the database and deletes or inserts what has different. I wanted to implement this in my application, but I did not understand how I would do it.
I have the following table:
id id_setor_empresa id_exame
1 5 3
2 5 20
3 5 17
That stores which exams should be done by employees in an industry.
Currently when an edit is made, I delete all the exams in the sector and register the new ones. How can I use sync
to do this in a "clean" way?