PointServiceProvider.php 950 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. <?php
  2. namespace App\Module\Point\Providers;
  3. use Illuminate\Support\ServiceProvider;
  4. use Illuminate\Support\Facades\Event;
  5. use App\Module\Farm\Events\CropPlantedEvent;
  6. use App\Module\Point\Listeners\PlantingPointsListener;
  7. /**
  8. * 积分模块服务提供者
  9. *
  10. * 负责注册积分模块的服务、配置和路由
  11. */
  12. class PointServiceProvider extends ServiceProvider
  13. {
  14. /**
  15. * 注册服务
  16. *
  17. * @return void
  18. */
  19. public function register()
  20. {
  21. }
  22. /**
  23. * 启动服务
  24. *
  25. * @return void
  26. */
  27. public function boot()
  28. {
  29. // 注册事件监听器
  30. $this->registerEventListeners();
  31. }
  32. /**
  33. * 注册事件监听器
  34. *
  35. * @return void
  36. */
  37. protected function registerEventListeners()
  38. {
  39. // 监听作物种植事件,自动增加种植点数
  40. Event::listen(CropPlantedEvent::class, PlantingPointsListener::class);
  41. }
  42. }