public function scopeListsTranslations(Builder $query, $translationField)
{
$withFallback = $this->useFallback();
$translationTable = $this->getTranslationsTable();
$localeKey = $this->getLocaleKey();
$query->select($this->getTable() . '.' . $this->getKeyName(), $translationTable . '.' . $translationField)->leftJoin($translationTable, $translationTable . '.' . $this->getRelationKey(), '=', $this->getTable() . '.' . $this->getKeyName())->where($translationTable . '.' . $localeKey, $this->locale());
if ($withFallback) {
$query->orWhere(function (Builder $q) use($translationTable, $localeKey) {
$q->where($translationTable . '.' . $localeKey, $this->getFallbackLocale())->whereNotIn($translationTable . '.' . $this->getRelationKey(), function (QueryBuilder $q) use($translationTable, $localeKey) {
$q->select($translationTable . '.' . $this->getRelationKey())->from($translationTable)->where($translationTable . '.' . $localeKey, $this->locale());
});
});
}
}