| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119 |
- <?php
- namespace App\Module\Admin\Events;
- use Illuminate\Foundation\Events\Dispatchable;
- use Illuminate\Queue\SerializesModels;
- /**
- * 管理员操作事件
- */
- class AdminActionEvent
- {
- use Dispatchable, SerializesModels;
- /**
- * @var array
- */
- public array $actionData;
- /**
- * 创建新的事件实例
- *
- * @param array $actionData
- */
- public function __construct(array $actionData)
- {
- $this->actionData = $actionData;
- }
- /**
- * 获取操作数据
- *
- * @return array
- */
- public function getActionData(): array
- {
- return $this->actionData;
- }
- /**
- * 获取管理员ID
- *
- * @return int|null
- */
- public function getAdminId(): ?int
- {
- return $this->actionData['admin_id'] ?? null;
- }
- /**
- * 获取管理员名称
- *
- * @return string
- */
- public function getAdminName(): string
- {
- return $this->actionData['admin_name'] ?? 'Unknown';
- }
- /**
- * 获取操作类型
- *
- * @return string
- */
- public function getActionType(): string
- {
- return $this->actionData['action_type'] ?? '';
- }
- /**
- * 获取操作描述
- *
- * @return string
- */
- public function getDescription(): string
- {
- return $this->actionData['description'] ?? '';
- }
- /**
- * 获取操作数据
- *
- * @return array
- */
- public function getData(): array
- {
- return $this->actionData['data'] ?? [];
- }
- /**
- * 获取IP地址
- *
- * @return string
- */
- public function getIpAddress(): string
- {
- return $this->actionData['ip_address'] ?? '';
- }
- /**
- * 获取用户代理
- *
- * @return string
- */
- public function getUserAgent(): string
- {
- return $this->actionData['user_agent'] ?? '';
- }
- /**
- * 获取时间戳
- *
- * @return \Carbon\Carbon|null
- */
- public function getTimestamp(): ?\Carbon\Carbon
- {
- return $this->actionData['timestamp'] ?? null;
- }
- }
|