Skip to content

Commit b76118a

Browse files
author
Tihomir Banov
committed
Add soft delete option to scopeWithTranslations method
1 parent 3dcd6aa commit b76118a

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

src/Despark/LaravelDbLocalization/i18nModelTrait.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ public function translate($locale = false)
110110
return $translation;
111111
}
112112

113-
public function scopeWithTranslations($query, $locale = null)
113+
public function scopeWithTranslations($query, $locale = null, $softDelete = null)
114114
{
115115
$i18nId = $this->getI18nId($locale);
116116
$translatorTable = new $this->translator();
@@ -124,6 +124,10 @@ public function scopeWithTranslations($query, $locale = null)
124124
$query = $query->where($translatorTableName.'.'.$this->getLocaleField(), '=', $i18nId);
125125
}
126126

127+
if ($softDelete) {
128+
$query = $query->whereNULL($translatorTableName.'.deleted_at');
129+
}
130+
127131
return $query;
128132
}
129133

0 commit comments

Comments
 (0)