/** * Handle an incoming request. * * @param \Illuminate\Http\Request $request * @param \Closure $next * @return mixed */ public function handle($request, Closure $next) { $fallback_locale = Settings::getFallBackLocale(); $locales = Settings::getLocales(); if (!Session::has('locale') || !in_array(Session::get('locale'), $locales)) { Session::put('locale', $fallback_locale); } app()->setLocale(Session::get('locale')); return $next($request); }
/** * Handle fallback locale change * * @param FallbackLocaleRequest $request * @return Response */ public function putFallbackLocale(FallbackLocaleRequest $request) { Settings::where('param', 'fallback_locale')->update(['value' => $request->input('fallback_locale')]); Cache::flush('settings'); Session::put('settings_tab', 'fallback-locale'); // Check if try to set fallback locale that is not in the locales list if (!in_array($request->input('fallback_locale'), Settings::getLocales())) { flash()->warning(trans('settings.fallback_locale_not_in_list')); } else { flash()->success(trans('settings.fallback_locale_updated')); } return redirect()->back(); }