Dimsav\Translatable\Translatable::scopeWhereTranslation PHP Method

scopeWhereTranslation() public method

This scope filters results by checking the translation fields.
public scopeWhereTranslation ( Builder $query, string $key, string $value, string $locale = null ) : Builder | static
$query Illuminate\Database\Eloquent\Builder
$key string
$value string
$locale string
return Illuminate\Database\Eloquent\Builder | static
    public function scopeWhereTranslation(Builder $query, $key, $value, $locale = null)
    {
        return $query->whereHas('translations', function (Builder $query) use($key, $value, $locale) {
            $query->where($this->getTranslationsTable() . '.' . $key, $value);
            if ($locale) {
                $query->where($this->getTranslationsTable() . '.' . $this->getLocaleKey(), $locale);
            }
        });
    }