mergeConfigFrom( __DIR__ . '/../config/socialfarm.php', 'socialfarm' ); } /** * 启动服务 */ public function boot(): void { // 发布配置文件 if ($this->app->runningInConsole()) { $this->publishes([ __DIR__ . '/../config/socialfarm.php' => config_path('socialfarm.php'), ], 'socialfarm-config'); } // 注册事件监听器 $this->registerEventListeners(); // 注册命令 $this->registerCommands(); } /** * 注册事件监听器 */ protected function registerEventListeners(): void { // 偷菜成功事件 Event::listen( \App\Module\SocialFarm\Events\CropStolenEvent::class, \App\Module\SocialFarm\Listeners\SendStealNotificationListener::class ); Event::listen( \App\Module\SocialFarm\Events\CropStolenEvent::class, \App\Module\SocialFarm\Listeners\UpdateSocialStatsListener::class ); // 农场访问事件 Event::listen( \App\Module\SocialFarm\Events\FarmVisitedEvent::class, \App\Module\SocialFarm\Listeners\UpdateSocialStatsListener::class ); // 互助行为事件 Event::listen( \App\Module\SocialFarm\Events\HelpActionEvent::class, \App\Module\SocialFarm\Listeners\UpdateSocialStatsListener::class ); } /** * 注册命令 */ protected function registerCommands(): void { if ($this->app->runningInConsole()) { $this->commands([ \App\Module\SocialFarm\Commands\CleanExpiredLogsCommand::class, \App\Module\SocialFarm\Commands\SocialFarmStatsCommand::class, ]); } } /** * 获取提供的服务 */ public function provides(): array { return []; } }