TenantAtlas/app/Notifications/ReviewPackStatusNotification.php
Ahmed Darrazi 2a1a708716 feat(109): complete Review Pack Export v1 — Phases 3-8
- ReviewPackService: generate, fingerprint dedupe, signed download URL
- GenerateReviewPackJob: 12-step pipeline, ZIP assembly, failure handling
- ReviewPackDownloadController: signed URL streaming with SHA-256 header
- ReviewPackResource: list/view pages, generate/expire/download actions
- TenantReviewPackCard: dashboard widget with 5 display states
- ReviewPackPolicy: RBAC via REVIEW_PACK_VIEW/MANAGE capabilities
- PruneReviewPacksCommand: retention automation + hard-delete option
- ReviewPackStatusNotification: database channel, ready/failed payloads
- Schedule: daily prune + entra admin roles, posture:dispatch deferred
- AlertRuleResource: hide sla_due from dropdown (backward compat kept)
- 59 passing tests across 7 test files (1 skipped: posture deferred)
- All 36 tasks completed per tasks.md
2026-02-23 11:00:47 +01:00

92 lines
2.6 KiB
PHP

<?php
declare(strict_types=1);
namespace App\Notifications;
use App\Models\ReviewPack;
use App\Models\Tenant;
use Filament\Actions\Action;
use Illuminate\Notifications\Notification;
class ReviewPackStatusNotification extends Notification
{
public function __construct(
public ReviewPack $reviewPack,
public string $status,
public ?string $reasonCode = null,
) {}
/**
* @return array<int, string>
*/
public function via(object $notifiable): array
{
return ['database'];
}
/**
* @return array<string, mixed>
*/
public function toDatabase(object $notifiable): array
{
$title = match ($this->status) {
'ready' => 'Review Pack ready',
'failed' => 'Review Pack generation failed',
default => 'Review Pack status updated',
};
$body = match ($this->status) {
'ready' => 'Your tenant review pack has been generated and is ready for download.',
'failed' => sprintf(
'Review pack generation failed%s.',
$this->reasonCode ? ": {$this->reasonCode}" : '',
),
default => 'Review pack status changed.',
};
$color = match ($this->status) {
'ready' => 'success',
'failed' => 'danger',
default => 'gray',
};
$icon = match ($this->status) {
'ready' => 'heroicon-o-document-arrow-down',
'failed' => 'heroicon-o-exclamation-triangle',
default => 'heroicon-o-document-text',
};
$actions = [];
$tenant = $this->reviewPack->tenant;
if ($tenant instanceof Tenant && $this->status === 'ready') {
$actions[] = Action::make('view_pack')
->label('View pack')
->url(route('filament.admin.resources.review-packs.view', [
'tenant' => $tenant->external_id,
'record' => $this->reviewPack->getKey(),
]))
->toArray();
}
return [
'format' => 'filament',
'title' => $title,
'body' => $body,
'color' => $color,
'duration' => 'persistent',
'actions' => $actions,
'icon' => $icon,
'iconColor' => $color,
'status' => null,
'view' => null,
'viewData' => [
'review_pack_id' => $this->reviewPack->getKey(),
'status' => $this->status,
'reason_code' => $this->reasonCode,
],
];
}
}