50 lines
1.1 KiB
PHP
50 lines
1.1 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace App\Models;
|
|
|
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
|
use Illuminate\Database\Eloquent\Model;
|
|
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
|
use Illuminate\Database\Eloquent\Relations\BelongsToMany;
|
|
use Illuminate\Database\Eloquent\Relations\HasMany;
|
|
|
|
class AlertDestination extends Model
|
|
{
|
|
use HasFactory;
|
|
|
|
public const string TYPE_TEAMS_WEBHOOK = 'teams_webhook';
|
|
|
|
public const string TYPE_EMAIL = 'email';
|
|
|
|
protected $guarded = [];
|
|
|
|
protected $hidden = [
|
|
'config',
|
|
];
|
|
|
|
protected $casts = [
|
|
'is_enabled' => 'boolean',
|
|
'config' => 'encrypted:array',
|
|
];
|
|
|
|
public function workspace(): BelongsTo
|
|
{
|
|
return $this->belongsTo(Workspace::class);
|
|
}
|
|
|
|
public function rules(): BelongsToMany
|
|
{
|
|
return $this->belongsToMany(AlertRule::class, 'alert_rule_destinations')
|
|
->using(AlertRuleDestination::class)
|
|
->withPivot(['id', 'workspace_id'])
|
|
->withTimestamps();
|
|
}
|
|
|
|
public function deliveries(): HasMany
|
|
{
|
|
return $this->hasMany(AlertDelivery::class);
|
|
}
|
|
}
|