Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

sardar1592's avatar

How to update pivot table values automatically

I have two separate tables 'students' and 'tutors'. I also have the pivot table 'students_tutors' set up with two values 'students_studentid' and 'tutors_tutid'. In the flow of things, the client wants to assign tutors to students and vice versa, when adding them or by editing them later. So a student may have many tutors and a tutor may have many students. Now I want the pivot table values to be automatically updated when such a selection occurs. Multiple tutors/students may be assigned in one go. I am having difficulty with auto update on the pivot table. I am quite new to Laravel. Can anyone suggest how to go about it and what code to use and where to update pivot values and display in view.

0 likes
0 replies

Please or to participate in this conversation.