'array', 'selected_accounts' => 'array', 'import_options' => 'array', 'import_log' => 'array', 'errors' => 'array', 'started_at' => 'datetime', 'completed_at' => 'datetime', 'remote_password' => 'encrypted', 'remote_api_token' => 'encrypted', ]; public function accounts(): HasMany { return $this->hasMany(ServerImportAccount::class); } public function addLog(string $message): void { $log = $this->import_log ?? []; $log[] = [ 'time' => now()->toDateTimeString(), 'message' => $message, ]; $this->update(['import_log' => $log]); } public function addError(string $error): void { $errors = $this->errors ?? []; $errors[] = [ 'time' => now()->toDateTimeString(), 'error' => $error, ]; $this->update(['errors' => $errors]); } public function getStatusColorAttribute(): string { return match ($this->status) { 'pending' => 'gray', 'discovering' => 'info', 'ready' => 'warning', 'importing' => 'info', 'completed' => 'success', 'failed' => 'danger', 'cancelled' => 'gray', default => 'gray', }; } public function getCompletedAccountsCountAttribute(): int { return $this->accounts()->where('status', 'completed')->count(); } public function getTotalAccountsCountAttribute(): int { return $this->accounts()->count(); } }