private function setLocale($locale, $request)
    {
        // Check if is allowed and set default locale if not
        if (!language()->allowed($locale)) {
            $locale = config('app.locale');
        }

        if (Auth::check()) {
            Auth::user()->setAttribute('locale', $locale)->save();
        } else {
            $request->session()->put('locale', $locale);
        }
    }
private function setLocale($locale, $request)
    {
        // Check if is allowed and set default locale if not
        if (!language()->allowed($locale)) {
            $locale = config('app.locale');
        }

        if (Auth::check()) {
            Auth::user()->setAttribute('locale', $locale)->save();
        } else {
            $request->session()->put('locale', $locale);
        }
    }
private function setLocale ( $ locale , $ request ) { // Check if is allowed and set default locale if not if ( ! language ( ) -> allowed ( $ locale ) ) { $ locale = config ( 'app.locale' ) ; } if ( Auth :: check ( ) ) { Auth :: user ( ) -> setAttribute ( 'locale' , $ locale ) -> save ( ) ; } else { $ request -> session ( ) -> put ( 'locale' , $ locale ) ; } }
Set locale if it's allowed.

@param string                   $locale
@param \Illuminate\Http\Request $request
Set locale if it s allowed .