hello everyone,
I have a back button which looks
<a class="btn btn-default pull-right" href="{{URL::previous()}}">
This will go back go previous page on click, however it falls to "infinity loop" after switching language.
here is my routes for switch
Route::get('lang/{lang}', ['as'=>'lang.switch', 'uses'=>'LanguageController@switchLang']);
In my LangController
public function switchLang($lang)
{
if (array_key_exists($lang, Config::get('languages'))) {
Session::set('applocale', $lang);
}
return Redirect::back();
}
In my case,
At the beginning, says current page is "/post" , when I click create button I've been "/post/create". At this time, the back button in create page works fine, the link of URL::previous() would be "/post". However, when I switch lang at create page, it went to /lang/{lang} and then redirect back. Therefore the back button of create page after switching language is broken with URL::previous() "/post/create"
Hope you guys understand what I said :S
Thanks a lot