diff --git a/app/Models/ServiceTemplate.php b/app/Models/ServiceTemplate.php
new file mode 100644
index 0000000000..8a00745e50
--- /dev/null
+++ b/app/Models/ServiceTemplate.php
@@ -0,0 +1,95 @@
+service_template_id . '-' . $this->device_group_id;
+ }
+
+ // ---- Query Scopes ----
+
+ /**
+ * @param Builder $query
+ * @return Builder
+ */
+ public function scopeIsOk($query)
+ {
+ return $query->where([
+ ['service_ignore', '=', 0],
+ ['service_disabled', '=', 0],
+ ['service_status', '=', 0],
+ ]);
+ }
+
+ /**
+ * @param Builder $query
+ * @return Builder
+ */
+ public function scopeIsCritical($query)
+ {
+ return $query->where([
+ ['service_ignore', '=', 0],
+ ['service_disabled', '=', 0],
+ ['service_status', '=', 2],
+ ]);
+ }
+
+ /**
+ * @param Builder $query
+ * @return Builder
+ */
+ public function scopeIsWarning($query)
+ {
+ return $query->where([
+ ['service_ignore', '=', 0],
+ ['service_disabled', '=', 0],
+ ['service_status', '=', 1],
+ ]);
+ }
+
+ /**
+ * @param Builder $query
+ * @return Builder
+ */
+ public function scopeIsIgnored($query)
+ {
+ return $query->where([
+ ['service_ignore', '=', 1],
+ ['service_disabled', '=', 0],
+ ]);
+ }
+
+ /**
+ * @param Builder $query
+ * @return Builder
+ */
+ public function scopeIsDisabled($query)
+ {
+ return $query->where('service_disabled', 1);
+ }
+}
diff --git a/includes/html/modal/delete_service_template.inc.php b/includes/html/modal/delete_service_template.inc.php
deleted file mode 100644
index 7ad5cb4b2b..0000000000
--- a/includes/html/modal/delete_service_template.inc.php
+++ /dev/null
@@ -1,85 +0,0 @@
-
- *
- * This program is free software: you can redistribute it and/or modify it
- * under the terms of the GNU General Public License as published by the
- * Free Software Foundation, either version 3 of the License, or (at your
- * option) any later version. Please see LICENSE.txt at the top level of
- * the source code distribution for details.
- */
-
-if (Auth::user()->hasGlobalAdmin()) {
- ?>
-
-
-
-
-
-
-
Delete Service Template
-
-
Service Template will be deleted.
-
-
-
Please confirm that you would like to delete:
-
-
All Services created by this Template will also be deleted!.
-
-
-
-
-
-
-
-
-
diff --git a/includes/html/modal/discover_service_template.inc.php b/includes/html/modal/discover_service_template.inc.php
deleted file mode 100644
index 970167f555..0000000000
--- a/includes/html/modal/discover_service_template.inc.php
+++ /dev/null
@@ -1,78 +0,0 @@
-
- *
- * This program is free software: you can redistribute it and/or modify it
- * under the terms of the GNU General Public License as published by the
- * Free Software Foundation, either version 3 of the License, or (at your
- * option) any later version. Please see LICENSE.txt at the top level of
- * the source code distribution for details.
- */
-
-if (Auth::user()->hasGlobalAdmin()) {
- ?>
-
-
-
-
-
-
-
Apply Service Template
-
-
Service Template will be Applied.
-
-
-
Please confirm that you would like to discover Devices and apply this Service Template.
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/includes/html/modal/new_service_template.inc.php b/includes/html/modal/new_service_template.inc.php
deleted file mode 100644
index 08404444d1..0000000000
--- a/includes/html/modal/new_service_template.inc.php
+++ /dev/null
@@ -1,206 +0,0 @@
-
- *
- * This program is free software: you can redistribute it and/or modify it
- * under the terms of the GNU General Public License as published by the
- * Free Software Foundation, either version 3 of the License, or (at your
- * option) any later version. Please see LICENSE.txt at the top level of
- * the source code distribution for details.
- */
-
-if (Auth::user()->hasGlobalAdmin()) {
- foreach (dbFetchRows('SELECT * FROM `device_groups` ORDER BY `name`') as $device_group) {
- $device_group_id .= "';
- }
- //foreach (list_available_services() as $current_service) {
- // $servicesform .= "";
- //}
- // Build the types list.
- $dir = \LibreNMS\Config::get('nagios_plugins');
- if (file_exists($dir) && is_dir($dir)) {
- $files = scandir($dir);
- $dir .= DIRECTORY_SEPARATOR;
- foreach ($files as $file) {
- if (is_executable($dir . $file) && is_file($dir . $file) && strstr($file, 'check_')) {
- [,$check_name] = explode('_', $file, 2);
- $stype .= "";
- }
- }
- } ?>
-
-
-
-
-
-
-
Edit Services Template
-
-
Service Template will modified for the specified Device Group.
-
-
-
-
-
-
-
-
-
-
-
- *
- * This program is free software: you can redistribute it and/or modify it
- * under the terms of the GNU General Public License as published by the
- * Free Software Foundation, either version 3 of the License, or (at your
- * option) any later version. Please see LICENSE.txt at the top level of
- * the source code distribution for details.
- */
-
-if (Auth::user()->hasGlobalAdmin()) {
- ?>
-
-
-
-
-
-
-
Remove Services
-
-
Service Template will be Removed.
-
-
-
Please confirm that you would like to remove all Services created by this Service Template.