<?php
 namespace VnChocola\Module\Api;
 use TCMS\Module;
 use Route;
 use LayoutData;
 class FloorManager extends Module {
 protected function initialize() {
 }
 protected function registerRoutes() {
 Route::get('/floor-manager/getMapData', 'IndexController', 'getMapData')->name('getMapData');
 Route::get('/floor-manager/getComboboxData', 'IndexController', 'getComboboxData')->name('getComboboxData');
 Route::get('/floor-manager/getDistrictsByCity', 'IndexController', 'getDistrictsByCity')->name('getDistrictsByCity');
 Route::get('/floor-manager/setting', 'SettingController', 'getSetting')->name('setting');
 Route::post('/floor-manager/setting', 'SettingController', 'update')->name('update-setting');
 Route::post('/floor-manager/saveFloorSize', 'SettingController', 'saveFloorSize')->name('saveFloorSize');
 }
 public function registerComponent() {
 \Model::add('BranchsModel', \VnChocola\Model\BranchsModel::class, true);
 \Model::add('FloorsModel', \VnChocola\Model\FloorsModel::class, true);
 \Model::add('StaffsModel', \VnChocola\Model\StaffsModel::class, true);
 \Model::add('DrinksModel', \VnChocola\Model\DrinksModel::class, true);
 \Model::add('PurposesModel', \VnChocola\Model\PurposesModel::class, true);
 \Model::add('CitysModel', \VnChocola\Model\CitysModel::class, true);
 \Model::add('DistrictsModel', \VnChocola\Model\DistrictsModel::class, true);
 \Model::add('FloorManagerSettingModel', \VnChocola\Model\FloorManagerSettingModel::class, true);
 \Model::add('InsurranceModel', \VnChocola\Model\InsurranceModel::class, true);
 \Model::add('LoanCarModel', \VnChocola\Model\LoanCarModel::class, true);
 }
 public function boot() {
 }
 public function middleware(string $routeName, $auth) {
 switch($routeName) {
 case 'getMapData': case 'setting': return $auth->hasRole(\RoleGlobal::$role->viewFloorManager) || $auth->hasRole(\RoleGlobal::$role->designFloorManager);
 case 'getComboboxData': case 'getDistrictsByCity': return $auth->hasRole(\RoleGlobal::$role->viewFloorManager);
 case 'update-setting': return $auth->hasRole(\RoleGlobal::$role->settingFloorManager);
 break;
 case 'saveFloorSize': return $auth->hasRole(\RoleGlobal::$role->designFloorManager);
 break;
 default: return false;
 break;
 }
 }
 }
