TenantAtlas/app/Notifications/Alerts/EmailAlertNotification.php
ahmido 3ed275cef3 feat(alerts): Monitoring cluster + v1 resources (spec 099) (#121)
Implements spec `099-alerts-v1-teams-email`.

- Monitoring navigation: Alerts as a cluster under Monitoring; default landing is Alert deliveries.
- Tenant panel: Alerts points to `/admin/alerts` and the cluster navigation is hidden in tenant panel.
- Guard compliance: removes direct `Gate::` usage from Alert resources so `NoAdHocFilamentAuthPatternsTest` passes.

Verification:
- Full suite: `1348 passed, 7 skipped` (EXIT=0).

Co-authored-by: Ahmed Darrazi <ahmed.darrazi@live.de>
Reviewed-on: #121
2026-02-18 15:20:43 +00:00

53 lines
1.3 KiB
PHP

<?php
declare(strict_types=1);
namespace App\Notifications\Alerts;
use App\Models\AlertDelivery;
use Illuminate\Bus\Queueable;
use Illuminate\Notifications\Messages\MailMessage;
use Illuminate\Notifications\Notification;
class EmailAlertNotification extends Notification
{
use Queueable;
/**
* @param array<string, mixed> $payload
*/
public function __construct(
private readonly AlertDelivery $delivery,
private readonly array $payload,
) {}
/**
* @return array<int, string>
*/
public function via(object $notifiable): array
{
return ['mail'];
}
public function toMail(object $notifiable): MailMessage
{
$title = trim((string) ($this->payload['title'] ?? 'Alert'));
$body = trim((string) ($this->payload['body'] ?? 'A matching alert event was detected.'));
if ($title === '') {
$title = 'Alert';
}
if ($body === '') {
$body = 'A matching alert event was detected.';
}
return (new MailMessage)
->subject($title)
->line($body)
->line('Delivery ID: '.(int) $this->delivery->getKey())
->line('Event type: '.(string) $this->delivery->event_type)
->line('Status: '.(string) $this->delivery->status);
}
}