Answer the question
In order to leave comments, you need to log in
How to remove link model links?
Hello! It is impossible to delete from a DB the linking data in any way. Now I will explain.
There are 3 models: House , Flat , Room .
These models are in relationship:
- House one-to-many Flat ;
- Flat one-to-many Room .
To remove all links House in relation to Flat I use:
$house = House::find($id);
$house->flats()->delete();
$house = House::find($id);
$house->flats()->rooms()->delete();
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question