SystemLogCreatedEvent.php 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. <?php
  2. namespace App\Module\System\Events;
  3. use App\Module\System\Models\SystemLog;
  4. use Illuminate\Broadcasting\InteractsWithSockets;
  5. use Illuminate\Foundation\Events\Dispatchable;
  6. use Illuminate\Queue\SerializesModels;
  7. /**
  8. * 系统日志创建事件
  9. */
  10. class SystemLogCreatedEvent
  11. {
  12. use Dispatchable, InteractsWithSockets, SerializesModels;
  13. /**
  14. * 日志ID
  15. *
  16. * @var int
  17. */
  18. public int $id;
  19. /**
  20. * 日志类型
  21. *
  22. * @var string
  23. */
  24. public string $type;
  25. /**
  26. * 日志级别
  27. *
  28. * @var string
  29. */
  30. public string $level;
  31. /**
  32. * 日志消息
  33. *
  34. * @var string
  35. */
  36. public string $message;
  37. /**
  38. * 日志上下文
  39. *
  40. * @var array
  41. */
  42. public array $context;
  43. /**
  44. * 用户ID
  45. *
  46. * @var int|null
  47. */
  48. public ?int $userId;
  49. /**
  50. * 系统日志对象
  51. *
  52. * @var SystemLog
  53. */
  54. public SystemLog $log;
  55. /**
  56. * 创建一个新的事件实例
  57. *
  58. * @param SystemLog $log
  59. * @return void
  60. */
  61. public function __construct(SystemLog $log)
  62. {
  63. $this->id = $log->id;
  64. $this->type = $log->type;
  65. $this->level = $log->level;
  66. $this->message = $log->message;
  67. $this->context = $log->context ?? [];
  68. $this->userId = $log->user_id;
  69. $this->log = $log;
  70. }
  71. }