/** * @param Request $request * @param $locale * @return \Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector */ public function getSwitchLocale(Request $request, $locale) { // check if supported $supportedLanguagesKeys = \LaravelLocalization::getSupportedLanguagesKeys(); if (!in_array($locale, $supportedLanguagesKeys)) { abort(404); } // store in session session(['someline-locale' => $locale]); // check if has redirect url $redirect_url = '/'; if ($request->has('redirect_url')) { $redirect_url = $request->get('redirect_url'); } return redirect($redirect_url); }