Files
fotospiel-app/app/Notifications/Ops/PurchaseCreated.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

53 lines
2.2 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'] ?? [];
$subject = __('emails.ops.purchase.subject', ['package' => $package?->name ?? __('emails.package_limits.package_fallback')]);
$greeting = __('emails.ops.purchase.greeting');
return (new MailMessage)
->subject($subject)
->view('emails.notifications.basic', [
'title' => $subject,
'preheader' => $greeting,
'heroTitle' => $greeting,
'heroSubtitle' => $subject,
'lines' => [
__('emails.ops.purchase.tenant', ['tenant' => $tenant?->name ?? __('emails.tenant_feedback.unknown_tenant')]),
__('emails.ops.purchase.package', ['package' => $package?->name ?? __('emails.package_limits.package_fallback')]),
__('emails.ops.purchase.amount', ['amount' => $amount, 'currency' => '€']),
__('emails.ops.purchase.provider', ['provider' => $this->purchase->provider, 'id' => $this->purchase->provider_id ?? '—']),
__('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',
]),
],
'footer' => __('emails.ops.purchase.footer'),
]);
}
}