Implement package limit notification system
This commit is contained in:
@@ -0,0 +1,49 @@
|
||||
<?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 EventPackageGuestLimitNotification extends Notification implements ShouldQueue
|
||||
{
|
||||
use Queueable;
|
||||
|
||||
public function __construct(
|
||||
private readonly EventPackage $eventPackage,
|
||||
private readonly int $limit,
|
||||
) {}
|
||||
|
||||
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;
|
||||
|
||||
$eventName = $event?->name['de'] ?? $event?->name['en'] ?? $event?->name ?? __('emails.package_limits.event_fallback');
|
||||
$url = url('/tenant/events/'.($event?->slug ?? ''));
|
||||
|
||||
return (new MailMessage)
|
||||
->subject(__('emails.package_limits.guest_limit.subject', [
|
||||
'event' => $eventName,
|
||||
]))
|
||||
->greeting(__('emails.package_limits.guest_limit.greeting', [
|
||||
'name' => $tenant?->name ?? __('emails.package_limits.team_fallback'),
|
||||
]))
|
||||
->line(__('emails.package_limits.guest_limit.body', [
|
||||
'event' => $eventName,
|
||||
'package' => $package?->getNameForLocale() ?? $package?->name ?? __('emails.package_limits.package_fallback'),
|
||||
'limit' => $this->limit,
|
||||
]))
|
||||
->action(__('emails.package_limits.guest_limit.action'), $url)
|
||||
->line(__('emails.package_limits.footer'));
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user