I have a Users and Groups table in Laravel Rloquent ORM. A group can have multiple users, and a user can be in multiple groups, so I use a pivot table to implement many-to-many relationships. In reality, the relationship is not many-to-many, because each user can only be in one group, but the system was designed in this way. I gently delete the rows in the Users table, so if necessary, I can restore users later.
The problem is that when a user is deleted, the system automatically deletes the entry in the pivot table. This is always one entry. I did not behave like this, added the line protected $softDelete = true; to the Users model, so I donβt understand why the system automatically deletes summary data entries.
I do not want to softly delete the summary data records, I want only soft deletion and exclusively for users, and the system should not touch anything else.
I could create my own delete function that sets the deleted_at variable at the actual time, but that way I could not just enable soft delete by changing true to false if I need it.
Why does the system automatically delete summary records and how can I disable this behavior?
source share