<?php
 namespace VnChocola\Module\Api;
 use TCMS\Module;
 use Route;
 use Model;
 use LayoutData;
 class Hotcustomers extends Module {
 protected function initialize() {
 }
 protected function registerRoutes() {
 Route::get('/hot-customers', 'IndexController', 'getList')->name('index');
 Route::get('/hot-customers/{id}', 'IndexController', 'find')->name('find');
 Route::post('/hot-customers/create', 'IndexController', 'create')->name('create');
 Route::post('/hot-customers/update', 'IndexController', 'update')->name('update');
 Route::post('/hot-customers/delete', 'IndexController', 'delete')->name('delete');
 Route::post('/hot-customers/searchFrm','IndexController','searchFrm')->name("searchFrm");
 Route::post('/hot-customers/check_code', 'IndexController', 'check_code')->name('check_code');
 Route::post('/hot-customers/reminding','IndexController','reminding')->name("reminding");
 }
 public function registerComponent() {
 Model::add('HotCustomersModel', \VnChocola\Model\HotCustomersModel::class, true);
 Model::add('NewCarsModel', \VnChocola\Model\NewCarsModel::class, true);
 Model::add('WorkContentsModel', \VnChocola\Model\WorkContentsModel::class, true);
 }
 public function boot() {
 }
 public function middleware(string $routeName, $auth) {
 switch($routeName) {
 case 'create': case 'check_code': return $auth->hasRole(\RoleGlobal::$role->createHotCustomer);
 break;
 case 'update': return $auth->hasRole(\RoleGlobal::$role->updateHotCustomer);
 break;
 case 'index': case 'searchFrm': case 'searchWidthField': case 'searchWithCar': case 'reminding': case 'find': return $auth->hasRole(\RoleGlobal::$role->viewHotCustomer);
 break;
 case 'delete': return $auth->hasRole(\RoleGlobal::$role->deleteHotCustomer);
 break;
 default: return false;
 }
 }
 }
