<?php
 namespace VnChocola\Module\Api;
 use TCMS\Module;
 use Route;
 use Model;
 use LayoutData;
 class Staffs extends Module {
 protected function initialize() {
 }
 protected function registerRoutes() {
 Route::get('/staffs', 'IndexController', 'getList')->name('index');
 Route::get('/staffs/{id}', 'IndexController', 'find')->name('find');
 Route::post('/staffs/create', 'IndexController', 'create')->name('create');
 Route::post('/staffs/update', 'IndexController', 'update')->name('update');
 Route::post('/staffs/delete', 'IndexController', 'delete')->name('delete');
 Route::post('/staffs/isme', 'IndexController', 'getisme')->name('getisme');
 Route::post('/staffs/data-mobile', 'IndexController', 'getDataMobile')->name('getdata');
 }
 public function registerComponent() {
 Model::add('StaffsModel', \VnChocola\Model\StaffsModel::class, true);
 Model::add('CustomersModel', \VnChocola\Model\CustomersModel::class, true);
 Model::add('ReservesModel', \VnChocola\Model\ReservesModel::class, true);
 }
 public function boot() {
 }
 public function middleware(string $routeName, $auth) {
 switch ($routeName) {
 case 'index': case 'find': case 'getisme': case 'getdata': return $auth->hasRole(\RoleGlobal::$role->viewStaff);
 case 'create': return $auth->hasRole(\RoleGlobal::$role->createStaff);
 case 'update': return $auth->hasRole(\RoleGlobal::$role->updateStaff);
 case 'delete': return $auth->hasRole(\RoleGlobal::$role->deleteStaff);
 default: return false;
 }
 }
 }
 