mercredi 25 juillet 2018

How can I check the existence of a language before set of its session in laravel?

Hi. I Currently using this function in routes

Route::get('locale/{locale}', function ($locale) {
    \Session::put('locale', $locale);
    return redirect()->back();
});

for changing the language.

I want to check the language before the set of its session like this.

Route::get('locale/{locale}', function ($locale) {
    if(!exist($locale)){
         \Session::put('locale', 'en');
    }
    else{
         \Session::put('locale', $locale);    
    }
    return redirect()->back();
});

How can I Create a function like the above function?

the above function is an example and it is incorrect.



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire