vendredi 2 juin 2017

laravel one to many relation synchronize on update

Hi I have table design like below, theoretically relation of subjects and courses are many to many but I made one to many relation because of extra information in pivot table(course_subjects). My data entry form has course selection and multiple choosing option for subjects. For storing it working fine but for updating , is there any functions available like sync in many to many relation for one-to-many relation to check whether the subject already available in course or is the subject removed from course. I tried deleting all the subject first and re-enter all subject again but this is not reliable for me. How do i perform this? Thank you for your any help and suggestions

subjects

id | name
1  | Political Economy
2  | Development Economics
3  | Applied Econometrics

courses

id | name
1  | Development Economics
2  | Journalism and Mass Communication

course_subjects

id | course_id | subject_id | passmark | fullmark
1  | 1         | 1          | 50       | 100
2  | 1         | 2          | 50       | 100



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire