CropRemovedEvent.php 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. <?php
  2. namespace App\Module\Farm\Events;
  3. use App\Module\Farm\Models\FarmCrop;
  4. use App\Module\Farm\Models\FarmLand;
  5. use Illuminate\Broadcasting\InteractsWithSockets;
  6. use Illuminate\Foundation\Events\Dispatchable;
  7. use Illuminate\Queue\SerializesModels;
  8. /**
  9. * 作物铲除事件
  10. *
  11. * 当用户铲除土地上的作物时触发
  12. */
  13. class CropRemovedEvent
  14. {
  15. use Dispatchable, InteractsWithSockets, SerializesModels;
  16. /**
  17. * 用户ID
  18. *
  19. * @var int
  20. */
  21. public $userId;
  22. /**
  23. * 土地信息
  24. *
  25. * @var FarmLand
  26. */
  27. public $land;
  28. /**
  29. * 作物信息
  30. *
  31. * @var FarmCrop
  32. */
  33. public $crop;
  34. /**
  35. * 使用的工具物品ID(可选)
  36. *
  37. * @var int
  38. */
  39. public $toolItemId;
  40. /**
  41. * 铲除原因(可选)
  42. *
  43. * @var string|null
  44. */
  45. public $reason;
  46. /**
  47. * 是否为软删除
  48. *
  49. * @var bool
  50. */
  51. public $softDeleted;
  52. /**
  53. * 创建一个新的事件实例
  54. *
  55. * @param int $userId
  56. * @param FarmLand $land
  57. * @param FarmCrop $crop
  58. * @param int $toolItemId
  59. * @param string|null $reason
  60. * @param bool $softDeleted
  61. * @return void
  62. */
  63. public function __construct(
  64. int $userId,
  65. FarmLand $land,
  66. FarmCrop $crop,
  67. int $toolItemId = 0,
  68. ?string $reason = null,
  69. bool $softDeleted = true
  70. ) {
  71. $this->userId = $userId;
  72. $this->land = $land;
  73. $this->crop = $crop;
  74. $this->toolItemId = $toolItemId;
  75. $this->reason = $reason;
  76. $this->softDeleted = $softDeleted;
  77. }
  78. }