DisasterGeneratedEvent.php 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. <?php
  2. namespace App\Module\Farm\Events;
  3. use App\Module\Farm\Models\FarmCrop;
  4. use Illuminate\Broadcasting\InteractsWithSockets;
  5. use Illuminate\Foundation\Events\Dispatchable;
  6. use Illuminate\Queue\SerializesModels;
  7. /**
  8. * 灾害生成事件
  9. *
  10. * 当作物上生成灾害时触发
  11. */
  12. class DisasterGeneratedEvent
  13. {
  14. use Dispatchable, InteractsWithSockets, SerializesModels;
  15. /**
  16. * 用户ID
  17. *
  18. * @var int
  19. */
  20. public $userId;
  21. /**
  22. * 作物信息
  23. *
  24. * @var FarmCrop
  25. */
  26. public $crop;
  27. /**
  28. * 灾害类型
  29. *
  30. * @var int
  31. */
  32. public $disasterType;
  33. /**
  34. * 灾害信息
  35. *
  36. * @var array
  37. */
  38. public $disasterInfo;
  39. /**
  40. * 创建一个新的事件实例
  41. *
  42. * @param int $userId
  43. * @param FarmCrop $crop
  44. * @param int $disasterType
  45. * @param array $disasterInfo
  46. * @return void
  47. */
  48. public function __construct(int $userId, FarmCrop $crop, int $disasterType, array $disasterInfo)
  49. {
  50. $this->userId = $userId;
  51. $this->crop = $crop;
  52. $this->disasterType = $disasterType;
  53. $this->disasterInfo = $disasterInfo;
  54. }
  55. }