CropHarvestedEvent.php 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. <?php
  2. namespace App\Module\Farm\Events;
  3. use App\Module\Farm\Models\FarmCrop;
  4. use App\Module\Farm\Models\FarmHarvestLog;
  5. use App\Module\Farm\Models\FarmLand;
  6. use Illuminate\Broadcasting\InteractsWithSockets;
  7. use Illuminate\Foundation\Events\Dispatchable;
  8. use Illuminate\Queue\SerializesModels;
  9. /**
  10. * 作物收获事件
  11. *
  12. * 当用户收获作物时触发
  13. */
  14. class CropHarvestedEvent
  15. {
  16. use Dispatchable, InteractsWithSockets, SerializesModels;
  17. /**
  18. * 用户ID
  19. *
  20. * @var int
  21. */
  22. public $userId;
  23. /**
  24. * 土地信息
  25. *
  26. * @var FarmLand
  27. */
  28. public $land;
  29. /**
  30. * 作物信息
  31. *
  32. * @var FarmCrop
  33. */
  34. public $crop;
  35. /**
  36. * 收获记录
  37. *
  38. * @var FarmHarvestLog
  39. */
  40. public $harvestLog;
  41. /**
  42. * 产出物品ID
  43. *
  44. * @var int
  45. */
  46. public $outputItemId;
  47. /**
  48. * 产出数量
  49. *
  50. * @var int
  51. */
  52. public $outputAmount;
  53. /**
  54. * 创建一个新的事件实例
  55. *
  56. * @param int $userId
  57. * @param FarmLand $land
  58. * @param FarmCrop $crop
  59. * @param FarmHarvestLog $harvestLog
  60. * @param int $outputItemId
  61. * @param int $outputAmount
  62. * @return void
  63. */
  64. public function __construct(
  65. int $userId,
  66. FarmLand $land,
  67. FarmCrop $crop,
  68. FarmHarvestLog $harvestLog,
  69. int $outputItemId,
  70. int $outputAmount
  71. ) {
  72. $this->userId = $userId;
  73. $this->land = $land;
  74. $this->crop = $crop;
  75. $this->harvestLog = $harvestLog;
  76. $this->outputItemId = $outputItemId;
  77. $this->outputAmount = $outputAmount;
  78. }
  79. }