'boolean', 'tenant_allowlist' => 'array', 'cooldown_seconds' => 'integer', 'quiet_hours_enabled' => 'boolean', ]; public function workspace(): BelongsTo { return $this->belongsTo(Workspace::class); } public function destinations(): BelongsToMany { return $this->belongsToMany(AlertDestination::class, 'alert_rule_destinations') ->using(AlertRuleDestination::class) ->withPivot(['id', 'workspace_id']) ->withTimestamps(); } public function deliveries(): HasMany { return $this->hasMany(AlertDelivery::class); } public function appliesToTenant(int $tenantId): bool { if ($this->tenant_scope_mode !== self::TENANT_SCOPE_ALLOWLIST) { return true; } $allowlist = is_array($this->tenant_allowlist) ? $this->tenant_allowlist : []; $allowlist = array_values(array_unique(array_map(static fn (mixed $value): int => (int) $value, $allowlist))); return in_array($tenantId, $allowlist, true); } }