'integer', 'cleanup_type' => 'integer', 'before_count' => 'integer', 'after_count' => 'integer', 'deleted_records' => 'integer', 'execution_time' => 'float', 'conditions' => 'array', 'created_at' => 'datetime', 'updated_at' => 'datetime', ]; /** * 获取清理类型枚举 */ public function getCleanupTypeEnumAttribute(): CLEANUP_TYPE { return CLEANUP_TYPE::from($this->cleanup_type); } /** * 关联任务 */ public function task(): BelongsTo { return $this->belongsTo(CleanupTask::class, 'task_id'); } /** * 获取成功的日志 */ public function scopeSuccessful($query) { return $query->whereNull('error_message'); } /** * 获取失败的日志 */ public function scopeFailed($query) { return $query->whereNotNull('error_message'); } /** * 按表名筛选 */ public function scopeByTable($query, string $tableName) { return $query->where('table_name', $tableName); } /** * 按清理类型筛选 */ public function scopeByCleanupType($query, CLEANUP_TYPE $cleanupType) { return $query->where('cleanup_type', $cleanupType->value); } }