mirror of
https://github.com/librenms/librenms.git
synced 2024-10-07 16:52:45 +00:00
Fix Device::isUnderMaintenance() add location relation
This commit is contained in:
@@ -133,25 +133,25 @@ class Device extends BaseModel
|
||||
|
||||
public function isUnderMaintenance()
|
||||
{
|
||||
if (!$this->device_id) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$query = AlertSchedule::isActive()
|
||||
->join('alert_schedulables', 'alert_schedule.schedule_id', 'alert_schedulables.schedule_id')
|
||||
->where(function ($query) {
|
||||
$query->where(function ($query) {
|
||||
$query->where('alert_schedulable_type', 'device')
|
||||
->where('alert_schedulable_id', $this->device_id);
|
||||
->where(function (Builder $query) {
|
||||
$query->whereHas('devices', function (Builder $query) {
|
||||
$query->where('alert_schedulables.alert_schedulable_id', $this->device_id);
|
||||
});
|
||||
|
||||
if ($this->groups) {
|
||||
$query->orWhere(function ($query) {
|
||||
$query->where('alert_schedulable_type', 'device_group')
|
||||
->whereIn('alert_schedulable_id', $this->groups->pluck('id'));
|
||||
$query->orWhereHas('deviceGroups', function (Builder $query) {
|
||||
$query->whereIn('alert_schedulables.alert_schedulable_id', $this->groups->pluck('id'));
|
||||
});
|
||||
}
|
||||
|
||||
if ($this->location) {
|
||||
$query->orWhere(function ($query) {
|
||||
$query->where('alert_schedulable_type', 'location')
|
||||
->where('alert_schedulable_id', $this->location->id);
|
||||
$query->orWhereHas('locations', function (Builder $query) {
|
||||
$query->where('alert_schedulables.alert_schedulable_id', $this->location->id);
|
||||
});
|
||||
}
|
||||
});
|
||||
|
Reference in New Issue
Block a user