I have three tables, table1, table2, and table3. table1 is one-to-many to table2 and table2 is one-to-many to table3.
I want to invoke Table1::find($id)::delete() and have all the rows from table2 and table3 deleted as well.
I added the following to my tables:
Table1
public function delete()
{
$this->table2()->delete();
return parent::delete();
}
Table2
public function delete()
{
$this->table3()->delete();
return parent::delete();
}
However, my rows from table3 are not deleted. Table3's rows get deleted if I manually call the delete function from the model table2. The way I have written the code, shouldn't the delete() function from table2 be called when table1 calls it?