| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788 |
- <?php
- namespace App\Module\Farm\Events;
- use App\Module\Farm\Models\FarmCrop;
- use App\Module\Farm\Models\FarmLand;
- use Illuminate\Broadcasting\InteractsWithSockets;
- use Illuminate\Foundation\Events\Dispatchable;
- use Illuminate\Queue\SerializesModels;
- /**
- * 作物铲除事件
- *
- * 当用户铲除土地上的作物时触发
- */
- class CropRemovedEvent
- {
- use Dispatchable, InteractsWithSockets, SerializesModels;
- /**
- * 用户ID
- *
- * @var int
- */
- public $userId;
- /**
- * 土地信息
- *
- * @var FarmLand
- */
- public $land;
- /**
- * 作物信息
- *
- * @var FarmCrop
- */
- public $crop;
- /**
- * 使用的工具物品ID(可选)
- *
- * @var int
- */
- public $toolItemId;
- /**
- * 铲除原因(可选)
- *
- * @var string|null
- */
- public $reason;
- /**
- * 是否为软删除
- *
- * @var bool
- */
- public $softDeleted;
- /**
- * 创建一个新的事件实例
- *
- * @param int $userId
- * @param FarmLand $land
- * @param FarmCrop $crop
- * @param int $toolItemId
- * @param string|null $reason
- * @param bool $softDeleted
- * @return void
- */
- public function __construct(
- int $userId,
- FarmLand $land,
- FarmCrop $crop,
- int $toolItemId = 0,
- ?string $reason = null,
- bool $softDeleted = true
- ) {
- $this->userId = $userId;
- $this->land = $land;
- $this->crop = $crop;
- $this->toolItemId = $toolItemId;
- $this->reason = $reason;
- $this->softDeleted = $softDeleted;
- }
- }
|