<?php
 namespace VnChocola\Module\Master;
 use TCMS\Module;
 use Route;
 use Model;
 use LayoutData;
 class MasterCodeworks extends Module {
 protected function initialize() {
 }
 protected function registerRoutes() {
 Route::get('/code-works', 'IndexController', 'index')->name('index');
 Route::get('/code-works/create', 'IndexController', 'create')->name('create');
 Route::post('/code-works/create', 'IndexController', 'postCreate')->name('postCreate');
 Route::get('/code-works/update/{id}', 'IndexController', 'update')->name('update');
 Route::post('/code-works/update/{id}', 'IndexController', 'postUpdate')->name('update');
 Route::post('/code-works/delete', 'IndexController', 'postDelete')->name('delete');
 }
 public function registerComponent() {
 Model::add('CodeWorksModel',\VnChocola\Model\CodeWorksModel::class,true);
 }
 public function boot() {
 LayoutData::addMenuItem('codeworks', route('index'), lang('codework_model.name'), 'primary', function(\LayoutMenuItem $menuItem) {
 $menuItem->icon = 'fas fa-briefcase';
 $menuItem->middleware = function($auth) {
 return $auth->hasRole(\RoleGlobal::$role->superCodeWorkManager);
 }
;
 }
);
 }
 public function middleware(string $routeName, $auth) {
 return $auth->hasRole(\RoleGlobal::$role->superCodeWorkManager);
 }
 }
