2026-03-26 11:26:03 +01:00
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
namespace App\Notifications;
|
|
|
|
|
|
|
|
|
|
use App\Enums\NotificationType;
|
|
|
|
|
use App\Mail\NudgeNotificationMail;
|
|
|
|
|
use App\Models\Declaration;
|
|
|
|
|
use App\Models\User;
|
|
|
|
|
use Illuminate\Bus\Queueable;
|
|
|
|
|
use Illuminate\Contracts\Queue\ShouldQueue;
|
|
|
|
|
use Illuminate\Notifications\Notification;
|
|
|
|
|
|
|
|
|
|
class NudgeNotification extends Notification implements ShouldQueue
|
|
|
|
|
{
|
|
|
|
|
use Queueable;
|
|
|
|
|
|
|
|
|
|
public int $tries = 3;
|
|
|
|
|
|
|
|
|
|
public int $backoff = 60;
|
|
|
|
|
|
|
|
|
|
public bool $deleteWhenMissingModels = true;
|
|
|
|
|
|
|
|
|
|
public function __construct(
|
|
|
|
|
public Declaration $declaration,
|
|
|
|
|
public User $sender,
|
|
|
|
|
) {}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @return array<string>
|
|
|
|
|
*/
|
|
|
|
|
public function via(object $notifiable): array
|
|
|
|
|
{
|
|
|
|
|
return ['database', 'mail'];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @return array<string, mixed>
|
|
|
|
|
*/
|
|
|
|
|
public function toDatabase(object $notifiable): array
|
|
|
|
|
{
|
|
|
|
|
return [
|
|
|
|
|
'workspace_id' => $this->declaration->workspace_id,
|
|
|
|
|
'declaration_id' => $this->declaration->id,
|
|
|
|
|
'sender_id' => $this->sender->id,
|
|
|
|
|
'notification_type' => NotificationType::Nudge,
|
|
|
|
|
];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function toMail(object $notifiable): NudgeNotificationMail
|
|
|
|
|
{
|
2026-03-27 13:40:30 +01:00
|
|
|
return (new NudgeNotificationMail($this->declaration, $this->sender))
|
|
|
|
|
->to($notifiable->email);
|
2026-03-26 11:26:03 +01:00
|
|
|
}
|
|
|
|
|
}
|