From 62aa77c0a01fd024f9b611e17f591045d91966e6 Mon Sep 17 00:00:00 2001 From: Tony Murray Date: Mon, 24 Oct 2022 09:54:59 -0500 Subject: [PATCH] Fix AlertRule relationships (#14500) --- app/Models/AlertRule.php | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/app/Models/AlertRule.php b/app/Models/AlertRule.php index 36640bdddd..4caa4e107a 100644 --- a/app/Models/AlertRule.php +++ b/app/Models/AlertRule.php @@ -88,6 +88,16 @@ class AlertRule extends BaseModel public function devices(): BelongsToMany { - return $this->belongsToMany(\App\Models\Device::class, 'alert_device_map', 'device_id', 'device_id'); + return $this->belongsToMany(\App\Models\Device::class, 'alert_device_map', 'rule_id', 'device_id'); + } + + public function groups(): BelongsToMany + { + return $this->belongsToMany(\App\Models\DeviceGroup::class, 'alert_group_map', 'rule_id', 'group_id'); + } + + public function locations(): BelongsToMany + { + return $this->belongsToMany(\App\Models\Location::class, 'alert_location_map', 'rule_id'); } }