From 0e638d4d055e120e2b2bf70d69b36ad075acddb5 Mon Sep 17 00:00:00 2001 From: Jose Andres Tejerina Date: Mon, 27 Oct 2025 17:15:10 -0300 Subject: [PATCH] fix: change method for mapping in OtlStrategy --- app/Audit/AuditLogOtlpStrategy.php | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/app/Audit/AuditLogOtlpStrategy.php b/app/Audit/AuditLogOtlpStrategy.php index ee57b56f0..bce51957f 100644 --- a/app/Audit/AuditLogOtlpStrategy.php +++ b/app/Audit/AuditLogOtlpStrategy.php @@ -187,12 +187,21 @@ private function buildAuditLogData($entity, $subject, array $change_set, string private function getCollectionType(PersistentCollection $collection): string { - if (empty($collection) && empty($collection->getSnapshot())) { + try { + if (!method_exists($collection, 'getMapping')) { + return 'unknown'; + } + + $mapping = $collection->getMapping(); + + if (!isset($mapping['targetEntity']) || empty($mapping['targetEntity'])) { + return 'unknown'; + } + + return class_basename($mapping['targetEntity']); + } catch (\Exception $ex) { return 'unknown'; } - - $item = !empty($collection) ? $collection->first() : $collection->getSnapshot()[0]; - return class_basename($item); } private function getCollectionChanges(PersistentCollection $collection, array $change_set): array