2018-07-14 22:15:43 +01:00
|
|
|
<?php
|
|
|
|
/**
|
|
|
|
* app/Models/AlertTemplate.php
|
|
|
|
*
|
|
|
|
* Model for access to alert_templates table data
|
|
|
|
*
|
|
|
|
* 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.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
2021-02-09 00:29:04 +01:00
|
|
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
2018-07-14 22:15:43 +01:00
|
|
|
*
|
2021-02-09 00:29:04 +01:00
|
|
|
* @link https://www.librenms.org
|
2021-09-10 20:09:53 +02:00
|
|
|
*
|
2018-07-14 22:15:43 +01:00
|
|
|
* @copyright 2018 Neil Lathwood
|
|
|
|
* @author Neil Lathwood <gh+n@laf.io>
|
|
|
|
*/
|
|
|
|
|
|
|
|
namespace App\Models;
|
|
|
|
|
2023-04-17 13:51:35 +02:00
|
|
|
use Illuminate\Database\Eloquent\Relations\HasMany;
|
2021-03-31 17:28:47 +02:00
|
|
|
use Illuminate\Database\Eloquent\Relations\HasManyThrough;
|
|
|
|
|
2018-07-14 22:15:43 +01:00
|
|
|
class AlertTemplate extends BaseModel
|
|
|
|
{
|
|
|
|
public $timestamps = false;
|
|
|
|
|
|
|
|
// ---- Define Relationships ----
|
|
|
|
|
2023-04-17 13:51:35 +02:00
|
|
|
public function map(): HasMany
|
2018-07-14 22:15:43 +01:00
|
|
|
{
|
2020-04-21 14:28:48 +02:00
|
|
|
return $this->hasMany(\App\Models\AlertTemplateMap::class, 'alert_templates_id', 'id');
|
2018-07-14 22:15:43 +01:00
|
|
|
}
|
2020-11-23 07:32:17 +01:00
|
|
|
|
2021-03-31 17:28:47 +02:00
|
|
|
public function alert_rules(): HasManyThrough
|
2020-11-23 07:32:17 +01:00
|
|
|
{
|
|
|
|
return $this->hasManyThrough(\App\Models\AlertRule::class, \App\Models\AlertTemplateMap::class, 'alert_templates_id', 'id', 'id', 'alert_rule_id')
|
|
|
|
->select(['id' => 'alert_rules.id', 'name' => 'alert_rules.name'])
|
|
|
|
->orderBy('alert_rules.name');
|
|
|
|
}
|
2018-07-14 22:15:43 +01:00
|
|
|
}
|