40 lines
1.3 KiB
PHP
40 lines
1.3 KiB
PHP
<?php
|
|
|
|
namespace App\Notifications;
|
|
|
|
use App\Models\Tenant;
|
|
use Carbon\Carbon;
|
|
use Illuminate\Bus\Queueable;
|
|
use Illuminate\Contracts\Queue\ShouldQueue;
|
|
use Illuminate\Notifications\Messages\MailMessage;
|
|
use Illuminate\Notifications\Notification;
|
|
|
|
class InactiveTenantDeletionWarning extends Notification implements ShouldQueue
|
|
{
|
|
use Queueable;
|
|
|
|
public function __construct(private readonly Tenant $tenant, private readonly Carbon $plannedDeletion)
|
|
{
|
|
$this->afterCommit();
|
|
}
|
|
|
|
public function via(object $notifiable): array
|
|
{
|
|
return ['mail'];
|
|
}
|
|
|
|
public function toMail(object $notifiable): MailMessage
|
|
{
|
|
$locale = $this->tenant->user?->preferred_locale ?? app()->getLocale();
|
|
$formattedDate = $this->plannedDeletion->copy()->locale($locale)->translatedFormat('d. F Y');
|
|
|
|
return (new MailMessage)
|
|
->locale($locale)
|
|
->subject(__('profile.retention.warning_subject', [], $locale))
|
|
->line(__('profile.retention.line1', ['name' => $this->tenant->name], $locale))
|
|
->line(__('profile.retention.line2', ['date' => $formattedDate], $locale))
|
|
->line(__('profile.retention.line3', [], $locale))
|
|
->action(__('profile.retention.action', [], $locale), url('/login'));
|
|
}
|
|
}
|