Implement package limit notification system
This commit is contained in:
@@ -0,0 +1,46 @@
|
||||
<?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 EventPackageGalleryExpiredNotification extends Notification implements ShouldQueue
|
||||
{
|
||||
use Queueable;
|
||||
|
||||
public function __construct(private readonly EventPackage $eventPackage) {}
|
||||
|
||||
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.gallery_expired.subject', [
|
||||
'event' => $eventName,
|
||||
]))
|
||||
->greeting(__('emails.package_limits.gallery_expired.greeting', [
|
||||
'name' => $tenant?->name ?? __('emails.package_limits.team_fallback'),
|
||||
]))
|
||||
->line(__('emails.package_limits.gallery_expired.body', [
|
||||
'event' => $eventName,
|
||||
'package' => $package?->getNameForLocale() ?? $package?->name ?? __('emails.package_limits.package_fallback'),
|
||||
'date' => optional($this->eventPackage->gallery_expires_at)->toFormattedDateString(),
|
||||
]))
|
||||
->action(__('emails.package_limits.gallery_expired.action'), $url)
|
||||
->line(__('emails.package_limits.footer'));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,51 @@
|
||||
<?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 EventPackageGalleryExpiringNotification extends Notification implements ShouldQueue
|
||||
{
|
||||
use Queueable;
|
||||
|
||||
public function __construct(
|
||||
private readonly EventPackage $eventPackage,
|
||||
private readonly int $daysRemaining,
|
||||
) {}
|
||||
|
||||
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(trans_choice('emails.package_limits.gallery_warning.subject', $this->daysRemaining, [
|
||||
'event' => $eventName,
|
||||
'days' => $this->daysRemaining,
|
||||
]))
|
||||
->greeting(__('emails.package_limits.gallery_warning.greeting', [
|
||||
'name' => $tenant?->name ?? __('emails.package_limits.team_fallback'),
|
||||
]))
|
||||
->line(trans_choice('emails.package_limits.gallery_warning.body', $this->daysRemaining, [
|
||||
'event' => $eventName,
|
||||
'package' => $package?->getNameForLocale() ?? $package?->name ?? __('emails.package_limits.package_fallback'),
|
||||
'days' => $this->daysRemaining,
|
||||
'date' => optional($this->eventPackage->gallery_expires_at)->toFormattedDateString(),
|
||||
]))
|
||||
->action(__('emails.package_limits.gallery_warning.action'), $url)
|
||||
->line(__('emails.package_limits.footer'));
|
||||
}
|
||||
}
|
||||
@@ -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'));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,57 @@
|
||||
<?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 ?? ''));
|
||||
|
||||
return (new MailMessage)
|
||||
->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'),
|
||||
]))
|
||||
->line(__('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,
|
||||
]))
|
||||
->action(__('emails.package_limits.guest_threshold.action'), $url)
|
||||
->line(__('emails.package_limits.footer'));
|
||||
}
|
||||
}
|
||||
@@ -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 EventPackagePhotoLimitNotification 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.photo_limit.subject', [
|
||||
'event' => $eventName,
|
||||
]))
|
||||
->greeting(__('emails.package_limits.photo_limit.greeting', [
|
||||
'name' => $tenant?->name ?? __('emails.package_limits.team_fallback'),
|
||||
]))
|
||||
->line(__('emails.package_limits.photo_limit.body', [
|
||||
'event' => $eventName,
|
||||
'package' => $package?->getNameForLocale() ?? $package?->name ?? __('emails.package_limits.package_fallback'),
|
||||
'limit' => $this->limit,
|
||||
]))
|
||||
->action(__('emails.package_limits.photo_limit.action'), $url)
|
||||
->line(__('emails.package_limits.footer'));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,58 @@
|
||||
<?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 EventPackagePhotoThresholdNotification 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 ?? ''));
|
||||
|
||||
return (new MailMessage)
|
||||
->subject(__('emails.package_limits.photo_threshold.subject', [
|
||||
'event' => $eventName,
|
||||
'percentage' => $percentage,
|
||||
]))
|
||||
->greeting(__('emails.package_limits.photo_threshold.greeting', [
|
||||
'name' => $tenant?->name ?? __('emails.package_limits.team_fallback'),
|
||||
]))
|
||||
->line(__('emails.package_limits.photo_threshold.body', [
|
||||
'event' => $eventName,
|
||||
'package' => $package?->getNameForLocale() ?? $package?->name ?? __('emails.package_limits.package_fallback'),
|
||||
'percentage' => $percentage,
|
||||
'used' => $this->used,
|
||||
'limit' => $this->limit,
|
||||
'remaining' => $remaining,
|
||||
]))
|
||||
->action(__('emails.package_limits.photo_threshold.action'), $url)
|
||||
->line(__('emails.package_limits.footer'));
|
||||
}
|
||||
}
|
||||
42
app/Notifications/Packages/TenantCreditsLowNotification.php
Normal file
42
app/Notifications/Packages/TenantCreditsLowNotification.php
Normal file
@@ -0,0 +1,42 @@
|
||||
<?php
|
||||
|
||||
namespace App\Notifications\Packages;
|
||||
|
||||
use App\Models\Tenant;
|
||||
use Illuminate\Bus\Queueable;
|
||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
use Illuminate\Notifications\Messages\MailMessage;
|
||||
use Illuminate\Notifications\Notification;
|
||||
|
||||
class TenantCreditsLowNotification extends Notification implements ShouldQueue
|
||||
{
|
||||
use Queueable;
|
||||
|
||||
public function __construct(
|
||||
private readonly Tenant $tenant,
|
||||
private readonly int $balance,
|
||||
private readonly int $threshold,
|
||||
) {}
|
||||
|
||||
public function via(object $notifiable): array
|
||||
{
|
||||
return ['mail'];
|
||||
}
|
||||
|
||||
public function toMail(object $notifiable): MailMessage
|
||||
{
|
||||
$url = url('/tenant/billing');
|
||||
|
||||
return (new MailMessage)
|
||||
->subject(__('emails.package_limits.credits_low.subject'))
|
||||
->greeting(__('emails.package_limits.credits_low.greeting', [
|
||||
'name' => $this->tenant->name ?? __('emails.package_limits.team_fallback'),
|
||||
]))
|
||||
->line(__('emails.package_limits.credits_low.body', [
|
||||
'balance' => $this->balance,
|
||||
'threshold' => $this->threshold,
|
||||
]))
|
||||
->action(__('emails.package_limits.credits_low.action'), $url)
|
||||
->line(__('emails.package_limits.footer'));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,46 @@
|
||||
<?php
|
||||
|
||||
namespace App\Notifications\Packages;
|
||||
|
||||
use App\Models\TenantPackage;
|
||||
use Illuminate\Bus\Queueable;
|
||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
use Illuminate\Notifications\Messages\MailMessage;
|
||||
use Illuminate\Notifications\Notification;
|
||||
|
||||
class TenantPackageEventLimitNotification extends Notification implements ShouldQueue
|
||||
{
|
||||
use Queueable;
|
||||
|
||||
public function __construct(
|
||||
private readonly TenantPackage $tenantPackage,
|
||||
private readonly int $limit,
|
||||
) {}
|
||||
|
||||
public function via(object $notifiable): array
|
||||
{
|
||||
return ['mail'];
|
||||
}
|
||||
|
||||
public function toMail(object $notifiable): MailMessage
|
||||
{
|
||||
$tenant = $this->tenantPackage->tenant;
|
||||
$package = $this->tenantPackage->package;
|
||||
|
||||
$url = url('/tenant/billing');
|
||||
|
||||
return (new MailMessage)
|
||||
->subject(__('emails.package_limits.event_limit.subject', [
|
||||
'package' => $package?->getNameForLocale() ?? $package?->name ?? __('emails.package_limits.package_fallback'),
|
||||
]))
|
||||
->greeting(__('emails.package_limits.event_limit.greeting', [
|
||||
'name' => $tenant?->name ?? __('emails.package_limits.team_fallback'),
|
||||
]))
|
||||
->line(__('emails.package_limits.event_limit.body', [
|
||||
'package' => $package?->getNameForLocale() ?? $package?->name ?? __('emails.package_limits.package_fallback'),
|
||||
'limit' => $this->limit,
|
||||
]))
|
||||
->action(__('emails.package_limits.event_limit.action'), $url)
|
||||
->line(__('emails.package_limits.footer'));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,55 @@
|
||||
<?php
|
||||
|
||||
namespace App\Notifications\Packages;
|
||||
|
||||
use App\Models\TenantPackage;
|
||||
use Illuminate\Bus\Queueable;
|
||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
use Illuminate\Notifications\Messages\MailMessage;
|
||||
use Illuminate\Notifications\Notification;
|
||||
|
||||
class TenantPackageEventThresholdNotification extends Notification implements ShouldQueue
|
||||
{
|
||||
use Queueable;
|
||||
|
||||
public function __construct(
|
||||
private readonly TenantPackage $tenantPackage,
|
||||
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
|
||||
{
|
||||
$tenant = $this->tenantPackage->tenant;
|
||||
$package = $this->tenantPackage->package;
|
||||
|
||||
$percentage = (int) round($this->threshold * 100);
|
||||
$remaining = max(0, $this->limit - $this->used);
|
||||
|
||||
$url = url('/tenant/billing');
|
||||
|
||||
return (new MailMessage)
|
||||
->subject(__('emails.package_limits.event_threshold.subject', [
|
||||
'package' => $package?->getNameForLocale() ?? $package?->name ?? __('emails.package_limits.package_fallback'),
|
||||
'percentage' => $percentage,
|
||||
]))
|
||||
->greeting(__('emails.package_limits.event_threshold.greeting', [
|
||||
'name' => $tenant?->name ?? __('emails.package_limits.team_fallback'),
|
||||
]))
|
||||
->line(__('emails.package_limits.event_threshold.body', [
|
||||
'package' => $package?->getNameForLocale() ?? $package?->name ?? __('emails.package_limits.package_fallback'),
|
||||
'percentage' => $percentage,
|
||||
'used' => $this->used,
|
||||
'limit' => $this->limit,
|
||||
'remaining' => $remaining,
|
||||
]))
|
||||
->action(__('emails.package_limits.event_threshold.action'), $url)
|
||||
->line(__('emails.package_limits.footer'));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,43 @@
|
||||
<?php
|
||||
|
||||
namespace App\Notifications\Packages;
|
||||
|
||||
use App\Models\TenantPackage;
|
||||
use Illuminate\Bus\Queueable;
|
||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
use Illuminate\Notifications\Messages\MailMessage;
|
||||
use Illuminate\Notifications\Notification;
|
||||
|
||||
class TenantPackageExpiredNotification extends Notification implements ShouldQueue
|
||||
{
|
||||
use Queueable;
|
||||
|
||||
public function __construct(private readonly TenantPackage $tenantPackage) {}
|
||||
|
||||
public function via(object $notifiable): array
|
||||
{
|
||||
return ['mail'];
|
||||
}
|
||||
|
||||
public function toMail(object $notifiable): MailMessage
|
||||
{
|
||||
$tenant = $this->tenantPackage->tenant;
|
||||
$package = $this->tenantPackage->package;
|
||||
|
||||
$url = url('/tenant/billing');
|
||||
|
||||
return (new MailMessage)
|
||||
->subject(__('emails.package_limits.package_expired.subject', [
|
||||
'package' => $package?->getNameForLocale() ?? $package?->name ?? __('emails.package_limits.package_fallback'),
|
||||
]))
|
||||
->greeting(__('emails.package_limits.package_expired.greeting', [
|
||||
'name' => $tenant?->name ?? __('emails.package_limits.team_fallback'),
|
||||
]))
|
||||
->line(__('emails.package_limits.package_expired.body', [
|
||||
'package' => $package?->getNameForLocale() ?? $package?->name ?? __('emails.package_limits.package_fallback'),
|
||||
'date' => optional($this->tenantPackage->expires_at)->toFormattedDateString(),
|
||||
]))
|
||||
->action(__('emails.package_limits.package_expired.action'), $url)
|
||||
->line(__('emails.package_limits.footer'));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,48 @@
|
||||
<?php
|
||||
|
||||
namespace App\Notifications\Packages;
|
||||
|
||||
use App\Models\TenantPackage;
|
||||
use Illuminate\Bus\Queueable;
|
||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
use Illuminate\Notifications\Messages\MailMessage;
|
||||
use Illuminate\Notifications\Notification;
|
||||
|
||||
class TenantPackageExpiringNotification extends Notification implements ShouldQueue
|
||||
{
|
||||
use Queueable;
|
||||
|
||||
public function __construct(
|
||||
private readonly TenantPackage $tenantPackage,
|
||||
private readonly int $daysRemaining,
|
||||
) {}
|
||||
|
||||
public function via(object $notifiable): array
|
||||
{
|
||||
return ['mail'];
|
||||
}
|
||||
|
||||
public function toMail(object $notifiable): MailMessage
|
||||
{
|
||||
$tenant = $this->tenantPackage->tenant;
|
||||
$package = $this->tenantPackage->package;
|
||||
|
||||
$url = url('/tenant/billing');
|
||||
|
||||
return (new MailMessage)
|
||||
->subject(trans_choice('emails.package_limits.package_expiring.subject', $this->daysRemaining, [
|
||||
'package' => $package?->getNameForLocale() ?? $package?->name ?? __('emails.package_limits.package_fallback'),
|
||||
'days' => $this->daysRemaining,
|
||||
]))
|
||||
->greeting(__('emails.package_limits.package_expiring.greeting', [
|
||||
'name' => $tenant?->name ?? __('emails.package_limits.team_fallback'),
|
||||
]))
|
||||
->line(trans_choice('emails.package_limits.package_expiring.body', $this->daysRemaining, [
|
||||
'package' => $package?->getNameForLocale() ?? $package?->name ?? __('emails.package_limits.package_fallback'),
|
||||
'days' => $this->daysRemaining,
|
||||
'date' => optional($this->tenantPackage->expires_at)->toFormattedDateString(),
|
||||
]))
|
||||
->action(__('emails.package_limits.package_expiring.action'), $url)
|
||||
->line(__('emails.package_limits.footer'));
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user