Skip to content
This repository has been archived by the owner on Jun 18, 2019. It is now read-only.

Commit

Permalink
Delete via model instead of QueryBuilder (#361)
Browse files Browse the repository at this point in the history
* Delete via model instead of Builder

In order to fire deleted events, delete via the model instance instead of directly on the Query/Builder.

* StyleCI
  • Loading branch information
andersLAL authored and dimsav committed Jun 7, 2017
1 parent 58182a0 commit 1e520ca
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/Translatable/Translatable.php
Original file line number Diff line number Diff line change
Expand Up @@ -765,10 +765,13 @@ public function getDefaultLocale()
public function deleteTranslations($locales = null)
{
if ($locales === null) {
$this->translations()->delete();
$translations = $this->translations()->get();
} else {
$locales = (array) $locales;
$this->translations()->whereIn($this->getLocaleKey(), $locales)->delete();
$translations = $this->translations()->whereIn($this->getLocaleKey(), $locales)->get();
}
foreach ($translations as $translation) {
$translation->delete();
}

// we need to manually "reload" the collection built from the relationship
Expand Down

0 comments on commit 1e520ca

Please sign in to comment.