Files
ladill-transfer/app/Notifications/TransferRecipientNotification.php
T
isaaccladandCursor c396c97ce2
Deploy Ladill Transfer / deploy (push) Successful in 36s
Fix transfer share links and redesign recipient download email.
Use transfer.ladill.com share URLs in notifications and APIs, add the email
logo, and show file details with a prominent download button.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-06-08 15:56:06 +00:00

63 lines
1.9 KiB
PHP

<?php
namespace App\Notifications;
use App\Models\Transfer;
use Illuminate\Bus\Queueable;
use Illuminate\Notifications\Messages\MailMessage;
use Illuminate\Notifications\Notification;
class TransferRecipientNotification extends Notification
{
use Queueable;
public function __construct(
private readonly Transfer $transfer,
private readonly string $milestone,
) {}
public function via(mixed $notifiable): array
{
return ['mail'];
}
public function toMail(mixed $notifiable): MailMessage
{
$transfer = $this->transfer->loadMissing(['files', 'qrCode', 'user']);
$publicUrl = $transfer->qrCode?->shareUrl() ?? '';
return (new MailMessage())
->subject($this->subjectLine())
->view('mail.notifications.transfer-recipient', [
'transfer' => $transfer,
'publicUrl' => $publicUrl,
'milestone' => $this->milestone,
'senderName' => $transfer->user?->name,
'daysRemaining' => $this->daysRemaining(),
]);
}
private function subjectLine(): string
{
return match ($this->milestone) {
'created' => $this->transfer->user?->name
? "{$this->transfer->user->name} shared files with you"
: "Files shared with you: {$this->transfer->title}",
'grace' => "Download soon — {$this->transfer->title} needs payment",
'1' => "Last day to download: {$this->transfer->title}",
'3' => "3 days left to download: {$this->transfer->title}",
'7' => "Download reminder: {$this->transfer->title}",
default => "Download reminder: {$this->transfer->title}",
};
}
private function daysRemaining(): ?int
{
if (! is_numeric($this->milestone)) {
return null;
}
return (int) $this->milestone;
}
}