Created
March 20, 2015 04:15
-
-
Save naneri/e10f6802288291cae838 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
class BaseController extends Controller{ | |
... | |
/** | |
* setting up the locale | |
* @param [type] $locale - the parameter from the URL with the locale | |
*/ | |
public function setLocale($locale = Null) | |
{ | |
//If the locale is in the list of available locales - switch to that locale | |
if ( in_array( $locale , Config::get( 'app.locales' ) ) ) | |
{ | |
App::setLocale( $locale ); | |
Session::put( 'locale', $locale ); | |
Cookie::forever( 'locale', $locale ); | |
return Redirect::back(); | |
//otherwise throw 404 exception | |
}else{ | |
App::abort(404); | |
} | |
} | |
... | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment