<?php
 namespace VnChocola\Module\SuperAdmin;
 use TCMS\Module;
 use Route;
 use Model;
 use LayoutData;
 use LayoutMenuItem;
 class SpAdminUser extends Module {
 protected function initialize() {
 }
 protected function registerRoutes() {
 Route::get('/user', 'IndexController', 'index')->name('index');
 Route::get('/user/create', 'IndexController', 'create')->name('create');
 Route::post('/user/create', 'IndexController', 'postCreate')->name('postCreate');
 Route::get('/user/update/{id}', 'IndexController', 'update')->name('update');
 Route::post('/user/update/{id}', 'IndexController', 'postUpdate')->name('update');
 Route::post('/user/delete', 'IndexController', 'postDelete')->name('delete');
 }
 public function registerComponent() {
 Model::add('UserModel');
 Model::add('GroupUserModel', \VnChocola\Model\GroupUserModel::class, true);
 Model::add('StaffsModel', \VnChocola\Model\StaffsModel::class, true);
 Model::add('BranchsModel',\VnChocola\Model\BranchsModel::class,true);
 }
 public function boot() {
 LayoutData::addMenuItem('user', route('index'), lang('role.user'), 'primary', function(LayoutMenuItem $menuItem) {
 $menuItem->icon = 'fa fa-user';
 $menuItem->middleware = function($auth) {
 return $auth->hasRole(\RoleGlobal::$role->superUserManager);
 }
;
 }
);
 }
 public function middleware(string $routeName, $auth) {
 return $auth->hasRole(\RoleGlobal::$role->superUserManager);
 }
 }
