CropPickedEvent.php 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156
  1. <?php
  2. namespace App\Module\Farm\Events;
  3. use App\Module\Farm\Models\FarmLand;
  4. use App\Module\Farm\Models\FarmCrop;
  5. use App\Module\Farm\Models\FarmCropLog;
  6. use Illuminate\Foundation\Events\Dispatchable;
  7. use Illuminate\Queue\SerializesModels;
  8. /**
  9. * 作物摘取事件
  10. * 当作物被摘取时触发此事件
  11. */
  12. class CropPickedEvent
  13. {
  14. use Dispatchable, SerializesModels;
  15. /**
  16. * 摘取者ID
  17. *
  18. * @var int
  19. */
  20. public int $pickerId;
  21. /**
  22. * 农场主ID(通过作物获取)
  23. *
  24. * @var int
  25. */
  26. public int $ownerId;
  27. /**
  28. * 土地ID(通过作物获取)
  29. *
  30. * @var int
  31. */
  32. public int $landId;
  33. /**
  34. * 作物ID(摘取目标)
  35. *
  36. * @var int
  37. */
  38. public int $cropId;
  39. /**
  40. * 摘取的物品ID
  41. *
  42. * @var int
  43. */
  44. public int $itemId;
  45. /**
  46. * 摘取数量
  47. *
  48. * @var int
  49. */
  50. public int $pickAmount;
  51. /**
  52. * 摘取前总数量
  53. *
  54. * @var int
  55. */
  56. public int $originalAmount;
  57. /**
  58. * 摘取后剩余数量
  59. *
  60. * @var int
  61. */
  62. public int $remainingAmount;
  63. /**
  64. * 摘取来源
  65. *
  66. * @var string
  67. */
  68. public string $pickSource;
  69. /**
  70. * 来源ID
  71. *
  72. * @var int|null
  73. */
  74. public ?int $sourceId;
  75. /**
  76. * 土地信息对象
  77. *
  78. * @var FarmLand
  79. */
  80. public FarmLand $land;
  81. /**
  82. * 作物信息对象
  83. *
  84. * @var FarmCrop
  85. */
  86. public FarmCrop $crop;
  87. /**
  88. * 作物日志记录对象
  89. *
  90. * @var FarmCropLog
  91. */
  92. public FarmCropLog $cropLog;
  93. /**
  94. * 创建新的事件实例
  95. *
  96. * @param int $pickerId 摘取者ID
  97. * @param int $ownerId 农场主ID
  98. * @param int $landId 土地ID
  99. * @param int $cropId 作物ID
  100. * @param int $itemId 摘取的物品ID
  101. * @param int $pickAmount 摘取数量
  102. * @param int $originalAmount 摘取前总数量
  103. * @param int $remainingAmount 摘取后剩余数量
  104. * @param string $pickSource 摘取来源
  105. * @param int|null $sourceId 来源ID
  106. * @param FarmLand $land 土地信息对象
  107. * @param FarmCrop $crop 作物信息对象
  108. * @param FarmCropLog $cropLog 作物日志记录对象
  109. */
  110. public function __construct(
  111. int $pickerId,
  112. int $ownerId,
  113. int $landId,
  114. int $cropId,
  115. int $itemId,
  116. int $pickAmount,
  117. int $originalAmount,
  118. int $remainingAmount,
  119. string $pickSource,
  120. ?int $sourceId,
  121. FarmLand $land,
  122. FarmCrop $crop,
  123. FarmCropLog $cropLog
  124. ) {
  125. $this->pickerId = $pickerId;
  126. $this->ownerId = $ownerId;
  127. $this->landId = $landId;
  128. $this->cropId = $cropId;
  129. $this->itemId = $itemId;
  130. $this->pickAmount = $pickAmount;
  131. $this->originalAmount = $originalAmount;
  132. $this->remainingAmount = $remainingAmount;
  133. $this->pickSource = $pickSource;
  134. $this->sourceId = $sourceId;
  135. $this->land = $land;
  136. $this->crop = $crop;
  137. $this->cropLog = $cropLog;
  138. }
  139. }