Files
fotospiel-app/app/Notifications/Packages/EventPackageGuestThresholdNotification.php
Codex Agent 207725d460 Converted all notification emails to the branded layout by routing them through a shared Blade template and swapping
the MailMessage builders to use view(). This keeps the existing copy/labels but aligns the look with resources/views/
  emails/partials/layout.blade.php. I also switched the customer add‑on receipt notification to reuse the existing
  branded view and added missing translations for the upload pipeline alert.
2025-12-23 14:03:42 +01:00

72 lines
2.5 KiB
PHP

<?php
namespace App\Notifications\Packages;
use App\Models\EventPackage;
use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Notifications\Messages\MailMessage;
use Illuminate\Notifications\Notification;
class EventPackageGuestThresholdNotification extends Notification implements ShouldQueue
{
use Queueable;
public function __construct(
private readonly EventPackage $eventPackage,
private readonly float $threshold,
private readonly int $limit,
private readonly int $used,
) {}
public function via(object $notifiable): array
{
return ['mail'];
}
public function toMail(object $notifiable): MailMessage
{
$event = $this->eventPackage->event;
$tenant = $event?->tenant;
$package = $this->eventPackage->package;
$percentage = (int) round($this->threshold * 100);
$remaining = max(0, $this->limit - $this->used);
$eventName = $event?->name['de'] ?? $event?->name['en'] ?? $event?->name ?? __('emails.package_limits.event_fallback');
$url = url('/tenant/events/'.($event?->slug ?? ''));
$subject = __('emails.package_limits.guest_threshold.subject', [
'event' => $eventName,
'percentage' => $percentage,
]);
$greeting = __('emails.package_limits.guest_threshold.greeting', [
'name' => $tenant?->name ?? __('emails.package_limits.team_fallback'),
]);
return (new MailMessage)
->subject($subject)
->view('emails.notifications.basic', [
'title' => $subject,
'preheader' => $greeting,
'heroTitle' => $greeting,
'heroSubtitle' => $subject,
'lines' => [
__('emails.package_limits.guest_threshold.body', [
'event' => $eventName,
'package' => $package?->getNameForLocale() ?? $package?->name ?? __('emails.package_limits.package_fallback'),
'percentage' => $percentage,
'used' => $this->used,
'limit' => $this->limit,
'remaining' => $remaining,
]),
],
'cta' => [
[
'label' => __('emails.package_limits.guest_threshold.action'),
'url' => $url,
],
],
'footer' => __('emails.package_limits.footer'),
]);
}
}