mirror of
https://github.com/librenms/librenms.git
synced 2024-10-07 16:52:45 +00:00
Solves error in discovering services module (#14939)
* Solves error discovering services module * Removing trailing spaces * Allow in device group scopes to accept an array * Fix and optimize queries a little --------- Co-authored-by: Tony Murray <murraytony@gmail.com>
This commit is contained in:
@@ -321,8 +321,8 @@ class ServiceTemplateController extends Controller
|
||||
ServiceTemplateController::applyDeviceGroups($template);
|
||||
|
||||
// remove any remaining services no longer in the correct device group
|
||||
foreach (Device::notInServiceTemplate($template->id)->notInDeviceGroup($template->groups)->get() as $device) {
|
||||
Service::where('device_id', $device->device_id)->where('service_template_id', $template->id)->delete();
|
||||
foreach (Device::notInServiceTemplate($template->id)->notInDeviceGroup($template->groups->pluck('id'))->pluck('device_id') as $device_id) {
|
||||
Service::where('device_id', $device_id)->where('service_template_id', $template->id)->delete();
|
||||
}
|
||||
$msg = __('All Service Templates have been applied');
|
||||
|
||||
|
@@ -14,6 +14,7 @@ use Illuminate\Database\Eloquent\Relations\HasManyThrough;
|
||||
use Illuminate\Database\Eloquent\Relations\HasOne;
|
||||
use Illuminate\Database\Eloquent\Relations\MorphToMany;
|
||||
use Illuminate\Database\Query\JoinClause;
|
||||
use Illuminate\Support\Arr;
|
||||
use Illuminate\Support\Str;
|
||||
use LibreNMS\Exceptions\InvalidIpException;
|
||||
use LibreNMS\Util\IP;
|
||||
@@ -567,7 +568,7 @@ class Device extends BaseModel
|
||||
$query->qualifyColumn('device_id'), function ($query) use ($deviceGroup) {
|
||||
$query->select('device_id')
|
||||
->from('device_group_device')
|
||||
->where('device_group_id', $deviceGroup);
|
||||
->whereIn('device_group_id', Arr::wrap($deviceGroup));
|
||||
}
|
||||
);
|
||||
}
|
||||
@@ -578,7 +579,7 @@ class Device extends BaseModel
|
||||
$query->qualifyColumn('device_id'), function ($query) use ($deviceGroup) {
|
||||
$query->select('device_id')
|
||||
->from('device_group_device')
|
||||
->where('device_group_id', $deviceGroup);
|
||||
->whereIn('device_group_id', Arr::wrap($deviceGroup));
|
||||
}
|
||||
);
|
||||
}
|
||||
|
Reference in New Issue
Block a user