protected function applyLocaleRestriction($query, $locale = null, $allowFallback = true)
    {
        $localeKey = $this->getLocaleKey();
        $locale    = $locale ?: app()->getLocale();
        $fallback  = $this->getFallbackLocale();

        if ($allowFallback && $fallback && $fallback != $locale) {

            $query->where(function ($query) use ($localeKey, $locale, $fallback) {
                $query
                    ->where($localeKey, $locale)
                    ->orWhere($localeKey, $fallback);
            });

            return;
        }

        $query->where($localeKey, $locale);
    }
protected function applyLocaleRestriction($query, $locale = null, $allowFallback = true)
    {
        $localeKey = $this->getLocaleKey();
        $locale    = $locale ?: app()->getLocale();
        $fallback  = $this->getFallbackLocale();

        if ($allowFallback && $fallback && $fallback != $locale) {

            $query->where(function ($query) use ($localeKey, $locale, $fallback) {
                $query
                    ->where($localeKey, $locale)
                    ->orWhere($localeKey, $fallback);
            });

            return;
        }

        $query->where($localeKey, $locale);
    }
protected function applyLocaleRestriction ( $ query , $ locale = null , $ allowFallback = true ) { $ localeKey = $ this -> getLocaleKey ( ) ; $ locale = $ locale ? : app ( ) -> getLocale ( ) ; $ fallback = $ this -> getFallbackLocale ( ) ; if ( $ allowFallback && $ fallback && $ fallback != $ locale ) { $ query -> where ( function ( $ query ) use ( $ localeKey , $ locale , $ fallback ) { $ query -> where ( $ localeKey , $ locale ) -> orWhere ( $ localeKey , $ fallback ) ; } ) ; return ; } $ query -> where ( $ localeKey , $ locale ) ; }
Applies locale-based restriction to a translations relation query.

@param Builder     $query
@param null|string $locale
@param bool        $allowFallback
Applies locale - based restriction to a translations relation query .