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

Delete via model instead of QueryBuilder #361

Merged
merged 2 commits into from
Jun 7, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions src/Translatable/Translatable.php
Original file line number Diff line number Diff line change
Expand Up @@ -725,10 +725,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