Skip to content
This repository has been archived by the owner on Aug 17, 2021. It is now read-only.

Commit

Permalink
Merge pull request #3 from koenhoeijmakers/feature-delete-translations
Browse files Browse the repository at this point in the history
purge translations when in "eloquent.deleting" event
  • Loading branch information
koenhoeijmakers authored Jun 5, 2018
2 parents d63ff9f + e87c770 commit 6a8dbb3
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions src/HasTranslations.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,10 @@ public static function bootHasTranslations()
});
}

static::deleting(function (self $model) {
$model->purgeTranslations();
});

static::addGlobalScope(new JoinTranslationScope());
}

Expand All @@ -63,6 +67,16 @@ public function translationExists(string $locale): bool
return $this->translations()->where($this->getLocaleKeyName(), $locale)->exists();
}

/**
* Purge the translations.
*
* @return mixed
*/
public function purgeTranslations()
{
return $this->translations()->delete();
}

/**
* Get the translation model.
*
Expand Down

0 comments on commit 6a8dbb3

Please sign in to comment.