Skip to content

Commit af07470

Browse files
committed
feat: add scope for retrieving root translations
1 parent a69e397 commit af07470

1 file changed

Lines changed: 6 additions & 0 deletions

File tree

src/DbTranslatable/IsDbTranslatable.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
namespace Javaabu\Translatable\DbTranslatable;
44

5+
use Illuminate\Database\Eloquent\Builder;
56
use Javaabu\Translatable\Contracts\Translatable;
67
use Javaabu\Translatable\Exceptions\CannotDeletePrimaryTranslationException;
78
use Javaabu\Translatable\Exceptions\FieldNotAllowedException;
@@ -248,6 +249,11 @@ public function isRootTranslation(): bool
248249
return empty($this->translatable_parent_id);
249250
}
250251

252+
public function scopeRootTranslations(Builder $builder)
253+
{
254+
return $builder->whereNull('translatable_parent_id');
255+
}
256+
251257
/**
252258
* Check if the current translation can update its parent translation.
253259
*/

0 commit comments

Comments
 (0)