From cf422b834ca3653c063f26d764ecfdbf8f9b7f88 Mon Sep 17 00:00:00 2001 From: Tony Murray Date: Thu, 30 May 2024 23:32:22 -0500 Subject: [PATCH] Fix duplicate maps in relationship (#16081) When a device is added to a map multiple times, it caused the map to show multiple times in the device overview. --- app/Models/Device.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/app/Models/Device.php b/app/Models/Device.php index cb8fc794ba8b..b5235181691e 100644 --- a/app/Models/Device.php +++ b/app/Models/Device.php @@ -802,7 +802,8 @@ public function macs(): HasMany public function maps(): HasManyThrough { - return $this->hasManyThrough(CustomMap::class, CustomMapNode::class, 'device_id', 'custom_map_id', 'device_id', 'custom_map_id'); + return $this->hasManyThrough(CustomMap::class, CustomMapNode::class, 'device_id', 'custom_map_id', 'device_id', 'custom_map_id') + ->distinct(); } public function mefInfo(): HasMany