Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Delete related data #10

Open
outOFFspace opened this issue Feb 9, 2017 · 1 comment
Open

Delete related data #10

outOFFspace opened this issue Feb 9, 2017 · 1 comment

Comments

@outOFFspace
Copy link

outOFFspace commented Feb 9, 2017

Add into afterDelete method deleting related translations data. Just like this:
public function afterDelete() { if ($this->translations) { PostTranslation::deleteAll(['post_id' => $this->id]); } }

@ivan-cc
Copy link

ivan-cc commented Feb 23, 2017

Лучше beforeDelete, т.к. по-хорошему у таблиц должны быть связи через innodb-relations.
Но если указана связь ON DELETE CASCADE, то оно и так само прекрасно удалиться.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants