<?php
 namespace VnChocola\Module\Api;
 use TCMS\Module;
 use Route;
 use Model;
 use LayoutData;
 class Reserves extends Module {
 protected function initialize() {
 }
 protected function registerRoutes() {
 Route::get('/reserves', 'IndexController', 'getList')->name('index');
 Route::post('/reserves/create', 'IndexController', 'create')->name('create');
 Route::post('/reserves/update', 'IndexController', 'update')->name('update');
 Route::post('/reserves/delete', 'IndexController', 'delete')->name('delete');
 Route::post('/reserves/check_code', 'IndexController', 'check_code')->name('check_code');
 Route::post('/reserves/today_visit', 'IndexController', 'today_visit')->name('today_visit');
 Route::get('/reserves/getReserveToDay', 'IndexController', 'getReserveToDay')->name('getReserveToDay');
 Route::get('/reserves/getAllReserveToDay', 'IndexController', 'getAllReserveToDay')->name('getAllReserveToDay');
 Route::post('/reserves/customers/find', 'IndexController', 'find_customers')->name('find_customers');
 Route::post('/reserves/scheduler_data', 'IndexController', 'scheduler_data')->name('scheduler_data');
 Route::post('/reserves/reserves_data', 'IndexController', 'reserves_data')->name('reserves_data');
 Route::post('/reserves/scheduler_update', 'IndexController', 'scheduler_update')->name('scheduler_update');
 Route::post('/reserves/scheduler_create', 'IndexController', 'scheduler_create')->name('scheduler_create');
 Route::get('/reserves/{id}', 'IndexController', 'find')->name('find');
 }
 public function registerComponent() {
 Model::add('StaffsModel', \VnChocola\Model\StaffsModel::class, true);
 Model::add('PurposesModel', \VnChocola\Model\PurposesModel::class, true);
 Model::add('CustomersModel', \VnChocola\Model\CustomersModel::class, true);
 Model::add('ReservesModel', \VnChocola\Model\ReservesModel::class, true);
 Model::add('CarsInfoModel', \VnChocola\Model\CarsInfoModel::class, true);
 Model::add('VisitCustomersModel', \VnChocola\Model\VisitCustomersModel::class, true);
 }
 public function boot() {
 }
 public function middleware(string $routeName, $auth) {
 switch($routeName) {
 case 'create': case 'check_code': case 'scheduler_create': return $auth->hasRole(\RoleGlobal::$role->createReserve);
 break;
 case 'update': case 'scheduler_update': return $auth->hasRole(\RoleGlobal::$role->updateReserve);
 break;
 case 'index': case 'find_customers': case 'today_visit': case 'find': case 'reserves_data': case 'scheduler_data': return $auth->hasRole(\RoleGlobal::$role->viewReserve);
 break;
 case 'delete': return $auth->hasRole(\RoleGlobal::$role->deleteReserve);
 break;
 case 'getReserveToDay': return $auth->hasRole(\RoleGlobal::$role->viewFloorManager);
 break;
 case 'getAllReserveToDay': return $auth->hasRole(\RoleGlobal::$role->viewCompartmentManager);
 break;
 default: return false;
 }
 }
 }
