Skip to content

Commit c59a97d

Browse files
committed
simplify delete loop
1 parent 7a99836 commit c59a97d

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

src/Translatable/Translatable.php

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ public static function bootTranslatable(): void
3636
});
3737

3838
static::deleted(function (Model $model) {
39+
/* @var Translatable $model */
3940
if (self::$deleteTranslationsCascade === true) {
4041
return $model->deleteTranslations();
4142
}
@@ -103,9 +104,7 @@ public function deleteTranslations($locales = null): void
103104
$translations = $this->translations()->whereIn($this->getLocaleKey(), $locales)->get();
104105
}
105106

106-
foreach ($translations as $translation) {
107-
$translation->delete();
108-
}
107+
$translations->each->delete();
109108

110109
// we need to manually "reload" the collection built from the relationship
111110
// otherwise $this->translations()->get() would NOT be the same as $this->translations

0 commit comments

Comments
 (0)