Pivot table model events on attach/detach/sync
Hi currently I'm trying to build a small classroom management app and part of the work flow is that, when a teacher assign a student to a specific course (new entry added to students_courses pivot table), a few stuffs will fire off. Creating a few other extra records in other tables Similarly when a student is taken away from a course, deleted model event for the pivot table should fire and remove those extra records as well.
I created a model named StudentCourse and had my created model event method. However, unless I do
StudentCourse::create([...]);
the created model event method doesn't fire off at all (that is when I do attach/sync/detach) on Course model to Student.
Please or to participate in this conversation.