getMorphClass(), $resource->getKey())->afterCommit(); } catch (Throwable $e) { Log::warning('Could not queue managed DNS cleanup for a deleted resource.', [ 'resource_type' => $resource->getMorphClass(), 'resource_id' => $resource->getKey(), 'error' => $e->getMessage(), ]); } }); } private static function hasManagedDnsReferences(Model $resource): bool { $query = ManagedDnsRecordReference::query()->where(fn ($query) => $query ->where('resource_type', $resource->getMorphClass()) ->where('resource_id', $resource->getKey())); if ($resource instanceof Application) { $query->orWhere(fn ($query) => $query ->where('resource_type', (new ApplicationPreview)->getMorphClass()) ->whereIn('resource_id', ApplicationPreview::withTrashed()->where('application_id', $resource->getKey())->select('id'))); } return $query->exists(); } }