44 lines
1.8 KiB
PHP
44 lines
1.8 KiB
PHP
<?php
|
|
|
|
namespace App\Notifications\Ops;
|
|
|
|
use App\Models\PackagePurchase;
|
|
use Illuminate\Bus\Queueable;
|
|
use Illuminate\Contracts\Queue\ShouldQueue;
|
|
use Illuminate\Notifications\Messages\MailMessage;
|
|
use Illuminate\Notifications\Notification;
|
|
|
|
class PurchaseCreated extends Notification implements ShouldQueue
|
|
{
|
|
use Queueable;
|
|
|
|
public function __construct(private readonly PackagePurchase $purchase) {}
|
|
|
|
public function via(object $notifiable): array
|
|
{
|
|
return ['mail'];
|
|
}
|
|
|
|
public function toMail(object $notifiable): MailMessage
|
|
{
|
|
$tenant = $this->purchase->tenant;
|
|
$package = $this->purchase->package;
|
|
$amount = number_format((float) $this->purchase->price, 2);
|
|
$consents = $this->purchase->metadata['consents'] ?? [];
|
|
|
|
return (new MailMessage)
|
|
->subject(__('emails.ops.purchase.subject', ['package' => $package?->name ?? __('emails.package_limits.package_fallback')]))
|
|
->greeting(__('emails.ops.purchase.greeting'))
|
|
->line(__('emails.ops.purchase.tenant', ['tenant' => $tenant?->name ?? __('emails.tenant_feedback.unknown_tenant')]))
|
|
->line(__('emails.ops.purchase.package', ['package' => $package?->name ?? __('emails.package_limits.package_fallback')]))
|
|
->line(__('emails.ops.purchase.amount', ['amount' => $amount, 'currency' => '€']))
|
|
->line(__('emails.ops.purchase.provider', ['provider' => $this->purchase->provider, 'id' => $this->purchase->provider_id ?? '—']))
|
|
->line(__('emails.ops.purchase.consents', [
|
|
'legal' => $consents['legal_version'] ?? 'n/a',
|
|
'terms' => $consents['accepted_terms_at'] ?? 'n/a',
|
|
'waiver' => $consents['digital_content_waiver_at'] ?? 'n/a',
|
|
]))
|
|
->line(__('emails.ops.purchase.footer'));
|
|
}
|
|
}
|