'array', ]; public const TYPE_INSTALL = 'install'; public const TYPE_UNINSTALL = 'uninstall'; public const TYPE_UPDATE = 'update'; public const TYPE_ERROR = 'error'; public const TYPE_HEARTBEAT = 'heartbeat'; public const TYPE_PRINT = 'print'; public const TYPE_PLUGIN_UPDATE = 'plugin_update'; public function user(): BelongsTo { return $this->belongsTo(User::class); } public function plugin(): BelongsTo { return $this->belongsTo(PrintPlugin::class, 'plugin_id'); } public function job(): BelongsTo { return $this->belongsTo(PrintJob::class, 'job_id'); } /** * 记录日志 */ public static function record( int $userId, string $type, string $action, ?int $pluginId = null, ?int $jobId = null, ?array $data = null, ?string $ip = null, ?string $deviceId = null ): self { return self::create([ 'user_id' => $userId, 'type' => $type, 'action' => $action, 'plugin_id' => $pluginId, 'job_id' => $jobId, 'data' => $data, 'ip' => $ip, 'device_id' => $deviceId, ]); } }