/** * Change the application language. * * @param string * @return Response */ public function changeApplicationLanguage($code) { if ($language = \App\Language::whereCode($code)->first()) { event('language.change', $language); } return redirect(\URL::previous() ?: route('home')); }
/** * Set locale * * @param \Illuminate\Http\Request $request * @param \Closure $next * @return mixed */ public function handle($request, Closure $next) { $language = Session::get('language', Config::get('app.locale')); $current_lang = Language::whereCode($language)->firstOrFail(); App::setLocale($language); Carbon::setLocale($language); Session::set('current_lang', $current_lang); return $next($request); }