Answer the question
In order to leave comments, you need to log in
Where in Laravel can you override relationship methods (detach() and toggle())?
Hello.
I want to redefine Laravel methods of working with relationships.
In particular, toggle() and detach() so that they do not delete records from the pivot table, but simply change the flag (an additional field in the same table).
Where is the best place to do this?
And how then to inherit, etc.?
Thank you.
Answer the question
In order to leave comments, you need to log in
You can do it, but you don't have to. If you want to change the field - create your own relational objects, and override the methods you need as much as you like. Don't touch the default ones.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question