Set up Laravel notification system with NotificationType enum (5 types), NudgeNotification, DocumentUploadedNotification, and DeclarationOverdueNotification classes with database + mail channels. Add email templates, infrastructure tests, and fix existing NotificationController tests for workspace compatibility. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
43 lines
1005 B
PHP
43 lines
1005 B
PHP
<?php
|
|
|
|
namespace App\Notifications;
|
|
|
|
use App\Enums\NotificationType;
|
|
use App\Models\Declaration;
|
|
use Illuminate\Bus\Queueable;
|
|
use Illuminate\Contracts\Queue\ShouldQueue;
|
|
use Illuminate\Notifications\Notification;
|
|
|
|
class DocumentUploadedNotification extends Notification implements ShouldQueue
|
|
{
|
|
use Queueable;
|
|
|
|
public bool $deleteWhenMissingModels = true;
|
|
|
|
public function __construct(
|
|
public Declaration $declaration,
|
|
public int $clientId,
|
|
) {}
|
|
|
|
/**
|
|
* @return array<string>
|
|
*/
|
|
public function via(object $notifiable): array
|
|
{
|
|
return ['database'];
|
|
}
|
|
|
|
/**
|
|
* @return array<string, mixed>
|
|
*/
|
|
public function toDatabase(object $notifiable): array
|
|
{
|
|
return [
|
|
'workspace_id' => $this->declaration->workspace_id,
|
|
'declaration_id' => $this->declaration->id,
|
|
'client_id' => $this->clientId,
|
|
'notification_type' => NotificationType::DocumentUploaded,
|
|
];
|
|
}
|
|
}
|