registerCommands(); $this->registerValidates(); $this->registerMiddleWares(); $this->registerEvents(); $this->registerListeners(); $this->registerQuery(); } /** * * @time 2019年12月13日 * @return void */ protected function registerCommands(): void { $this->commands([ InstallCommand::class, ModuleCacheCommand::class, MigrateRunCommand::class, ModelGeneratorCommand::class, SeedRunCommand::class, BackupCommand::class, CompressPackageCommand::class, CreateModuleCommand::class, ]); } /** * * @time 2019年12月07日 * @return void */ protected function registerValidates(): void { $validates = [ new Sometimes(), ]; Validate::maker(function($validate) use ($validates){ foreach ($validates as $vali) { $validate->extend($vali->type(), [$vali, 'verify'], $vali->message()); } }); } /** * * @time 2019年12月12日 * @return void */ protected function registerMiddleWares(): void { $this->app->middleware->import([ 'catch_check_permission' => PermissionsMiddleware::class, ], 'route'); } /** * * @time 2019年12月12日 * @return void */ protected function registerEvents(): void { $this->app->event->bind([ 'loginLog' => LoginLogEvent::class, 'operateLog' => OperateLogEvent::class, ]); } /** * 注册监听者 * * @time 2019年12月12日 * @return void */ protected function registerListeners(): void { $this->app->event->listenEvents([ 'loginLog' => [ LoginLogListener::class, ], 'operateLog' => [ OperateLogListener::class, ], 'RouteLoaded' => [ LoadModuleRoutes::class ], ]); } protected function registerQuery() { $connections = $this->app->config->get('database.connections'); $connections['mysql']['query'] = CatchQuery::class; $this->app->config->set([ 'connections' => $connections ], 'database'); } }