PetCreatedEvent.php 989 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. <?php
  2. namespace App\Module\Pet\Events;
  3. use Illuminate\Broadcasting\InteractsWithSockets;
  4. use Illuminate\Foundation\Events\Dispatchable;
  5. use Illuminate\Queue\SerializesModels;
  6. /**
  7. * 宠物创建事件
  8. *
  9. * 当新宠物被创建时触发此事件,允许其他系统响应宠物的创建。
  10. * 此事件可用于记录宠物创建日志、更新用户状态、处理新手引导等。
  11. * 经过优化,只保留必要的用户ID和宠物ID属性。
  12. */
  13. class PetCreatedEvent
  14. {
  15. use Dispatchable, InteractsWithSockets, SerializesModels;
  16. /**
  17. * 用户ID
  18. *
  19. * @var int
  20. */
  21. public int $userId;
  22. /**
  23. * 宠物ID
  24. *
  25. * @var int
  26. */
  27. public int $petId;
  28. /**
  29. * 创建一个新的事件实例
  30. *
  31. * @param int $userId 用户ID
  32. * @param int $petId 宠物ID
  33. * @return void
  34. */
  35. public function __construct(int $userId, int $petId)
  36. {
  37. $this->userId = $userId;
  38. $this->petId = $petId;
  39. }
  40. }