public function scopeTranslatedIn(Builder $query, $locale = null) { $locale = $locale ?: $this->locale(); return $query->whereHas('translations', function (Builder $q) use($locale) { $q->where($this->getLocaleKey(), '=', $locale); }); }