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

Commit

Permalink
Merge branch 'master' of github.com:koenhoeijmakers/laravel-translatable
Browse files Browse the repository at this point in the history
  • Loading branch information
koenhoeijmakers committed Jun 5, 2018
2 parents f7c8a0c + 6a8dbb3 commit 0315953
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 0315953

Please sign in to comment.