setLocale() public static method

Set the default locale.
public static setLocale ( string $locale ) : void
$locale string
return void
Exemplo n.º 1
0
 public function postLogin()
 {
     if (Request::ajax()) {
         $userdata = array('usuario' => Input::get('usuario'), 'password' => Input::get('password'));
         if (Auth::attempt($userdata, Input::get('remember', 0))) {
             //buscar los permisos de este usuario y guardarlos en sesion
             $query = "SELECT m.nombre as modulo, s.nombre as submodulo,\n                        su.agregar, su.editar, su.eliminar,\n                        CONCAT(m.path,'.', s.path) as path, m.icon\n                        FROM modulos m \n                        JOIN submodulos s ON m.id=s.modulo_id\n                        JOIN submodulo_usuario su ON s.id=su.submodulo_id\n                        WHERE su.estado = 1 AND m.estado = 1 AND s.estado = 1\n                        and su.usuario_id = ?\n                        ORDER BY m.nombre, s.nombre ";
             $res = DB::select($query, array(Auth::id()));
             $menu = array();
             $accesos = array();
             foreach ($res as $data) {
                 $modulo = $data->modulo;
                 //$accesos[] = $data->path;
                 array_push($accesos, $data->path);
                 if (isset($menu[$modulo])) {
                     $menu[$modulo][] = $data;
                 } else {
                     $menu[$modulo] = array($data);
                 }
             }
             $usuario = Usuario::find(Auth::id());
             Session::set('language', 'Español');
             Session::set('language_id', 'es');
             Session::set('menu', $menu);
             Session::set('accesos', $accesos);
             Session::set('perfilId', $usuario['perfil_id']);
             Session::set("s_token", md5(uniqid(mt_rand(), true)));
             Lang::setLocale(Session::get('language_id'));
             return Response::json(array('rst' => '1', 'estado' => Auth::user()->estado));
         } else {
             $m = '<strong>Usuario</strong> y/o la <strong>contraseña</strong>';
             return Response::json(array('rst' => '2', 'msj' => 'El' . $m . 'son incorrectos.'));
         }
     }
 }
Exemplo n.º 2
0
 public function postLogin()
 {
     if (Request::ajax()) {
         $userdata = array('dni' => Input::get('usuario'), 'password' => Input::get('password'));
         if (Auth::attempt($userdata, Input::get('remember', 0))) {
             //buscar los permisos de este usuario y guardarlos en sesion
             $query = "  SELECT m.nombre as menu, o.nombre as opcion,o.visible,\n                            IF(LOCATE('.', o.ruta)>0,\n                                    o.ruta,\n                                    CONCAT(m.ruta,'.',o.ruta)\n                            ) as ruta, m.class_icono as icon,\n                            CONCAT(a.paterno, ' ', a.materno, ', ', a.nombres)\n                            as persona\n                            FROM activistas a\n                            JOIN activista_cargo ac ON ac.activista_id=a.id AND ac.estado=1\n                            JOIN cargos c ON c.id=ac.cargo_id AND c.estado=1\n                            JOIN cargo_opcion co ON co.cargo_id=c.id AND co.estado=1\n                            JOIN opciones o ON o.id=co.opcion_id AND o.estado=1\n                            JOIN menus m ON m.id=o.menu_id AND m.estado=1\n                            WHERE a.estado=1\n                            AND a.id=?\n                            GROUP BY m.id, o.id\n                            ORDER BY m.nombre, o.nombre";
             $res = DB::select($query, array(Auth::user()->id));
             $persona = 1;
             $menus = array();
             $accesos = array();
             foreach ($res as $data) {
                 $menu = $data->menu;
                 $persona = $data->persona;
                 //$accesos[] = $data->ruta;
                 array_push($accesos, $data->ruta);
                 if (isset($menus[$menu])) {
                     $menus[$menu][] = $data;
                 } else {
                     $menus[$menu] = array($data);
                 }
             }
             Session::set('language', 'Español');
             Session::set('language_id', 'es');
             Session::set('menus', $menus);
             Session::set('accesos', $accesos);
             Session::set('persona', $persona);
             Lang::setLocale(Session::get('language_id'));
             return Response::json(array('rst' => '1', 'estado' => Auth::user()->estado, 'query' => $query, 'menu' => $menus, 'acceso' => $accesos));
         } else {
             $m = ' y/o la <strong>contraseña</strong> son incorrectos.';
             return Response::json(array('rst' => '2', 'msj' => 'El <strong>Usuario</strong>' . $m));
         }
     }
 }
Exemplo n.º 3
0
 /**
  * Initializer.
  *
  * @access   public
  * @return BaseController
  */
 public function __construct()
 {
     $is_admin = Request::is('admin*');
     $is_backend = Request::is('backend*');
     /* Set middleware(s) based on route URLs */
     if ($is_admin || $is_backend) {
         $this->middleware('auth');
         if ($is_backend) {
             // Backend specific middleware
             $this->middleware('auth.backend');
         }
         $this->middleware('auth.permissions');
         if (!Request::is('*users/change-password')) {
             // No validation for stale password if password is being changed
             $this->middleware('auth.pw_6_months');
         }
     }
     list($this->link_type, $this->link, $this->layout, $this->current_theme) = current_section();
     View::share('link_type', $this->link_type);
     View::share('current_theme', $this->current_theme);
     $website_settings = Setting::lists('value', 'name')->all();
     View::share('website_settings', $website_settings);
     $locale = Setting::value('language');
     App::setLocale($locale);
     Lang::setLocale($locale);
     $this->user = current_user();
     View::share('current_user', $this->user);
     View::share('current_user_companies', current_user_companies());
 }
 public function setLocale($language)
 {
     //Change language
     \Session::set('locale', $language);
     \App::setLocale($language);
     \Lang::setLocale($language);
     //
     return \Redirect::back();
 }
Exemplo n.º 5
0
 /**
  * Initializer.
  *
  * @access   public
  * @return BaseController
  */
 public function __construct()
 {
     list($this->link_type, $this->link, $this->layout, $this->current_theme) = current_section();
     View::share('link_type', $this->link_type);
     View::share('current_theme', $this->current_theme);
     $website_settings = Setting::lists('value', 'name');
     View::share('website_settings', $website_settings);
     $locale = Setting::value('language');
     App::setLocale($locale);
     Lang::setLocale($locale);
     $this->user = current_user();
     View::share('current_user', $this->user);
     View::share('current_user_companies', current_user_companies());
 }
Exemplo n.º 6
0
 /**
  * @param Request $request
  * @param Response $response
  * return void
  */
 public function __construct(Request $request, Response $response, SessionStore $session, Guard $auth)
 {
     $this->request = $request;
     $this->response = $response;
     $this->session = $session;
     $this->currentUser = $auth->user();
     if (auth()->check()) {
         \Lang::setLocale($this->currentUser->locale);
     }
     $this->loginPath = \CMS::backendPath() . '/auth/login';
     // Execute method boot() on controller execute
     if (method_exists($this, 'boot')) {
         app()->call([$this, 'boot']);
     }
     if ($this->authRequired) {
         $this->beforeFilter('@checkPermissions');
     }
 }
Exemplo n.º 7
0
<?php

/*
|--------------------------------------------------------------------------
| Application & Route Filters
|--------------------------------------------------------------------------
|
| Below you will find the "before" and "after" events for the application
| which may be used to do any work before or after a request into your
| application. Here you may also register your custom route filters.
|
*/
App::before(function ($request) {
    //Lang::setLocale(Session::get('locale'));
    if (Session::has('locale')) {
        Lang::setLocale(Session::get('locale'));
    } else {
        Session::put('locale', Config::get('app.locale'));
    }
});
App::after(function ($request, $response) {
    //
});
/*
|--------------------------------------------------------------------------
| Authentication Filters
|--------------------------------------------------------------------------
|
| The following filters are used to verify that the user of the current
| session is logged into this application. The "basic" filter easily
| integrates HTTP Basic authentication for quick, simple checking.
Exemplo n.º 8
0
<?php

App::before(function ($request) {
    Lang::setLocale(Session::get('language_id'));
});
App::after(function ($request, $response) {
    //
});
Route::filter('auth', function () {
    if (Auth::guest()) {
        return Redirect::guest('/');
    }
});
Route::filter('auth.basic', function () {
    return Auth::basic("username");
});
Route::filter('guest', function () {
    if (Auth::check()) {
        return Redirect::to('/');
    }
});
Route::filter('csrf', function () {
    if (Session::token() !== Input::get('_token')) {
        throw new Illuminate\Session\TokenMismatchException();
    }
});
Route::filter('cumpleanios', function () {
    if (date("d/m") == "16/12") {
        return "Feliz Cumpleaños";
    }
});
Exemplo n.º 9
0
<?php

/**
 * Дополнительная настройка
 */
/**
 * Доп. заголовки
 */
Header::send('X-Powered-By: Knee');
/**
 * Указание языка
 */
Lang::setLocale('ru');
Exemplo n.º 10
0
|--------------------------------------------------------------------------
|
| Here is where you can register all of the routes for an application.
| It's a breeze. Simply tell Laravel the URIs it should respond to
| and give it the controller to call when that URI is requested.
|
*/
//Route::get('/', 'UploadsController@index');
//Route::get('upload', 'UploadsController@upload');
//Route::post('update','UploadsController@update');
Route::get('/', 'SignaturesController@getIndex');
Route::get('home', 'HomeController@index');
Route::controller('signatures', 'SignaturesController');
Route::controllers(['auth' => 'Auth\\AuthController', 'password' => 'Auth\\PasswordController']);
Route::filter('locale', function () {
    Lang::setLocale('vi');
});
Route::get('lang/en', 'SignaturesController@getLangEn');
Route::get('lang/vi', 'SignaturesController@getLangVi');
//Route::get('lang/vi', function () {
//    $location = GeoIP::getLocation('42.114.37.41');
////    $location = GeoIP::getLocation();
//
//    if ($location['isoCode'] == "VN") {
//        Lang::setLocale('vi');
//    } else {
//        Lang::setLocale('en');
//    }
//    return Redirect::to('signatures/index');
//});
//Route::get('lang/{lang}', ['as'=>'lang.switch', 'uses'=>'LanguageController@switchLang']);
Exemplo n.º 11
0
|
| Below you will find the "before" and "after" events for the application
| which may be used to do any work before or after a request into your
| application. Here you may also register your custom route filters.
|
*/
App::before(function ($request) {
    // Detect site language from browser and cookies.
    /* @var $request \Illuminate\Http\Request */
    if (Cookie::has('lang')) {
        $lang = Cookie::get('lang');
    } else {
        $lang = $request->getLocale();
    }
    App::setLocale($lang);
    Lang::setLocale($lang);
    // Update user's session expiration time.
    if (Auth::user()) {
        /* @var $user User */
        $user = Auth::user();
        $expires = new Carbon\Carbon();
        $expires->addMinutes(5);
        $user->session_expires = $expires;
        $user->save();
    }
});
App::after(function ($request, $response) {
    //
});
App::missing(function ($exception) {
    return Response::view('errors.404', array('url' => Request::url()), 404);
Exemplo n.º 12
0
<?php

// ===============================================
// localed routes SECTION =================================
// ===============================================
$locale = Request::segment(1);
\Lang::setLocale($locale);
Route::group(['prefix' => $locale, 'middleware' => 'locale'], function () {
    Route::post('/language', array('as' => 'language-chooser', 'uses' => 'LanguageController@chooser'));
    Route::get('/', ['uses' => 'HomeController@index', 'as' => 'main']);
    Route::group(['prefix' => '/', 'as' => 'itway::'], function () {
        //BLOG ROUTES START
        Route::group(['prefix' => 'blog', 'as' => 'posts::'], function () {
            Route::get('/', ['uses' => 'PostsController@index', 'as' => 'index']);
            Route::get('post/{slug}', ['uses' => 'PostsController@show', 'as' => 'show']);
            Route::get('create', ['uses' => 'PostsController@create', 'as' => 'create']);
            Route::get('user-posts', ['uses' => 'PostsController@userPosts', 'as' => 'user-posts']);
            Route::get('edit/{id}', ['uses' => 'PostsController@edit', 'as' => 'edit', 'middleware' => 'IsUsersOrAdminPost']);
            Route::patch('update/{id}', ['uses' => 'PostsController@update', 'as' => 'update', 'middleware' => 'IsUsersOrAdminPost']);
            Route::delete('delete/{id}', ['uses' => 'PostsController@destroy', 'as' => 'delete', 'middleware' => 'IsUsersOrAdminPost']);
            Route::post('store', ['uses' => 'PostsController@store', 'as' => 'store']);
            Route::get('/tags/{slug}', 'PostsController@tags');
        });
        //BLOG ROUTES END
        //EVENTS ROUTES START
        Route::group(array('prefix' => 'events', 'as' => 'events::'), function () {
            Route::get('/', ['uses' => 'EventsController@index', 'as' => 'index']);
            Route::get('show/{id}', ['as' => 'show', 'uses' => 'EventsController@show']);
            Route::get('personal_events', ['as' => 'personal_events', 'uses' => 'EventsController@personalEvents']);
            Route::get('create', ['uses' => 'EventsController@create', 'as' => 'create', 'middleware' => 'auth']);
            Route::get('edit/{id}', ['uses' => 'EventsController@edit', 'as' => 'edit', 'middleware' => ['auth']]);