with('owner')->findOrFail($this->customerId); if ($customer->status === 'active') { Log::info('ProvisionCustomerJob: customer already active', ['id' => $customer->id]); return; } $customer->update([ 'status' => 'pending', 'provisioning_step' => 'queued', 'error_message' => null, ]); $data = CustomerProvisionData::fromCustomer($customer); $provisioning->provision($customer, $data); if ($customer->owner) { $notifications->provisioningCompleted($customer->fresh(), $customer->owner); } } public function failed(?Throwable $exception): void { Log::error('ProvisionCustomerJob failed permanently', [ 'customer_id' => $this->customerId, 'error' => $exception?->getMessage(), ]); $customer = Customer::query()->with('owner')->find($this->customerId); if ($customer) { $customer->update([ 'status' => 'failed', 'error_message' => $exception?->getMessage() ?? 'Unknown provisioning failure', ]); if ($customer->owner) { app(HostingNotificationService::class)->provisioningFailed( $customer, $customer->owner, $customer->error_message ?? 'Unbekannter Fehler', ); } } } }