public function login()
 {
     Session::set('admin_lock_url', null);
     $loginForm = new KForm();
     $loginForm->addField(FormFieldBase::createByType('login', FormFieldBase::Type_Text)->setRules('required')->setLabel('请输入工号'));
     $loginForm->addField(FormFieldBase::createByType('password', FormFieldBase::Type_Password)->setRules('required')->setLabel('请输入密码'));
     if (AuthModel::user() !== null) {
         return Redirect::action('admin.index');
     }
     if (Request::isMethod('POST')) {
         //是管理员登陆请求
         if ($loginForm->validation()) {
             $login = $loginForm->value('login');
             $password = $loginForm->value('password');
             if (AuthModel::attempt(['employee_id' => $login, 'password' => $password])) {
                 $admin = AuthModel::getUser();
                 $admin->last_login = new \Carbon\Carbon();
                 $admin->save();
                 return Redirect::action('admin.index');
             } else {
                 $loginForm->set_error('password', '错误的用户名或密码');
             }
         } else {
             //
         }
     }
     $this->layout = View::make('laravel-cms::admin-lte/login')->with('form', $loginForm);
 }
 protected function setupLayout()
 {
     $this->layout = View::make('laravel-cms::layouts/admin-lte');
     $this->layout->content = '';
     $this->layout->title = '';
     $this->layout->site_name = Config::get('laravel-cms::site.name');
     $this->layout->css = [];
     $this->layout->js = [];
     $user = AuthModel::getUser();
     $menu = new AdminMenu($user);
     if (isset(static::$menu_name)) {
         $menu_name = static::$menu_name;
     } elseif (isset(static::$name)) {
         $menu_name = static::$name;
     } else {
         $menu_name = null;
     }
     $this->layout->shortcuts = $menu->getCurrentSubMenu($menu_name);
     $menu = $menu->getMenu();
     $this->layout->navbar = View::make('laravel-cms::admin-lte/navbar')->with('menu', $menu);
     $this->layout->usermenu = View::make('laravel-cms::admin-lte/user_menu')->with('user', AuthModel::getUser());
 }
 public static function checkMe($action, $parameters = null)
 {
     return static::check(AuthModel::getUser(), $action, $parameters);
 }