Skip to content

Instantly share code, notes, and snippets.

@naneri
Created March 20, 2015 04:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save naneri/e10f6802288291cae838 to your computer and use it in GitHub Desktop.
Save naneri/e10f6802288291cae838 to your computer and use it in GitHub Desktop.
<?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