259 lines
11 KiB
PHP
259 lines
11 KiB
PHP
<?php
|
|
|
|
namespace App\Mail;
|
|
|
|
use Illuminate\Bus\Queueable;
|
|
use Illuminate\Contracts\Queue\ShouldQueue;
|
|
use Illuminate\Mail\Mailable;
|
|
use Illuminate\Queue\SerializesModels;
|
|
use Illuminate\Support\Arr;
|
|
use Illuminate\Support\Str;
|
|
|
|
class SystemNotificationMail extends Mailable implements ShouldQueue
|
|
{
|
|
use Queueable, SerializesModels;
|
|
|
|
/** @var array<string,mixed> */
|
|
public array $data;
|
|
|
|
/**
|
|
* Create a new message instance.
|
|
*
|
|
* @param string $type Machine key for notification type (e.g. deposit, withdrawal, kyc_error)
|
|
* @param array<string,mixed> $payload Arbitrary data to render inside the template
|
|
*/
|
|
public function __construct(public string $type, array $payload = [])
|
|
{
|
|
$this->data = $this->buildData($type, $payload);
|
|
$this->subject($this->data['subject'] ?? (config('app.name') . ' Notification'));
|
|
}
|
|
|
|
/**
|
|
* Build the message.
|
|
*/
|
|
public function build()
|
|
{
|
|
return $this->view('emails.notification')
|
|
->with($this->data);
|
|
}
|
|
|
|
/**
|
|
* Default content map for supported notification types.
|
|
*
|
|
* @return array<string,array<string,mixed>>
|
|
*/
|
|
protected function map(): array
|
|
{
|
|
$app = config('app.name');
|
|
return [
|
|
// Finance
|
|
'deposit' => [
|
|
'subject' => "{$app}: Einzahlung eingegangen",
|
|
'title' => 'Einzahlung bestätigt',
|
|
'icon' => '💰',
|
|
'message' => 'Deine Einzahlung wurde erfolgreich verbucht.',
|
|
'cta' => ['label' => 'Wallet öffnen', 'url' => url('/wallet')],
|
|
],
|
|
'withdrawal' => [
|
|
'subject' => "{$app}: Auszahlung gestartet",
|
|
'title' => 'Auszahlung in Bearbeitung',
|
|
'icon' => '🏦',
|
|
'message' => 'Wir bearbeiten aktuell deine Auszahlung. Du erhältst eine weitere Benachrichtigung, sobald sie abgeschlossen ist.',
|
|
'cta' => ['label' => 'Verlauf ansehen', 'url' => url('/wallet')],
|
|
],
|
|
'bonus_available' => [
|
|
'subject' => "{$app}: Neuer Bonus verfügbar",
|
|
'title' => 'Bonus verfügbar',
|
|
'icon' => '🎁',
|
|
'message' => 'Es wartet ein neuer Bonus auf dich. Sichere ihn dir, bevor er abläuft!',
|
|
'cta' => ['label' => 'Bonus holen', 'url' => url('/bonuses')],
|
|
],
|
|
|
|
// Restrictions
|
|
'banned' => [
|
|
'subject' => "{$app}: Konto gesperrt",
|
|
'title' => 'Konto gesperrt',
|
|
'icon' => '⛔',
|
|
'message' => 'Dein Konto wurde vorübergehend gesperrt. Bitte kontaktiere den Support für weitere Informationen.',
|
|
'cta' => ['label' => 'Support kontaktieren', 'url' => url('/support')],
|
|
],
|
|
'chat_banned' => [
|
|
'subject' => "{$app}: Chat eingeschränkt",
|
|
'title' => 'Chat-Bann',
|
|
'icon' => '🚫',
|
|
'message' => 'Dein Chat-Zugang wurde eingeschränkt. Bitte beachte unsere Chat-Richtlinien.',
|
|
'cta' => ['label' => 'Richtlinien lesen', 'url' => url('/legal/terms')],
|
|
],
|
|
|
|
// Progress
|
|
'level_up' => [
|
|
'subject' => "{$app}: Level-Up!",
|
|
'title' => 'Glückwunsch zum Level-Up',
|
|
'icon' => '🚀',
|
|
'message' => 'Du bist ein Level aufgestiegen. Weiter so!',
|
|
'cta' => ['label' => 'VIP ansehen', 'url' => url('/vip-levels')],
|
|
],
|
|
'near_level_up' => [
|
|
'subject' => "{$app}: Kurz vor Level-Up",
|
|
'title' => 'Fast geschafft',
|
|
'icon' => '✨',
|
|
'message' => 'Du bist kurz davor, das nächste Level zu erreichen. Ein paar Punkte fehlen noch!',
|
|
'cta' => ['label' => 'Jetzt weiterspielen', 'url' => url('/')],
|
|
],
|
|
'inactivity_check' => [
|
|
'subject' => "{$app}: Vermissen dich! Bist du noch aktiv?",
|
|
'title' => 'Wir vermissen dich',
|
|
'icon' => '👋',
|
|
'message' => 'Wir haben dich eine Weile nicht gesehen. Schau vorbei, es gibt Neuigkeiten und Aktionen!',
|
|
'cta' => ['label' => 'Zurück zu ' . $app, 'url' => url('/')],
|
|
],
|
|
'friend_request' => [
|
|
'subject' => "{$app}: Neue Freundschaftsanfrage",
|
|
'title' => 'Freundschaftsanfrage',
|
|
'icon' => '🤝',
|
|
'message' => 'Du hast eine neue Freundschaftsanfrage erhalten.',
|
|
'cta' => ['label' => 'Anfragen ansehen', 'url' => url('/friends')],
|
|
],
|
|
|
|
// KYC
|
|
'kyc_error' => [
|
|
'subject' => "{$app}: KYC Fehler",
|
|
'title' => 'KYC nicht erfolgreich',
|
|
'icon' => '⚠️',
|
|
'message' => 'Leider konnte deine Identitätsprüfung nicht abgeschlossen werden. Bitte reiche die benötigten Dokumente erneut ein.',
|
|
'cta' => ['label' => 'KYC erneut starten', 'url' => url('/settings/kyc')],
|
|
],
|
|
'kyc_accepted' => [
|
|
'subject' => "{$app}: KYC akzeptiert",
|
|
'title' => 'KYC bestätigt',
|
|
'icon' => '✅',
|
|
'message' => 'Deine Identität wurde erfolgreich verifiziert. Vielen Dank!',
|
|
'cta' => ['label' => 'Zum Dashboard', 'url' => url('/dashboard')],
|
|
],
|
|
|
|
// Security
|
|
'email_2fa' => [
|
|
'subject' => "{$app}: 2FA Code",
|
|
'title' => 'Dein 2FA-Code',
|
|
'icon' => '🔐',
|
|
'message' => 'Verwende den folgenden Code, um dich anzumelden oder eine Aktion zu bestätigen.',
|
|
],
|
|
|
|
// Policies updates
|
|
'terms_updated' => [
|
|
'subject' => "{$app}: Nutzungsbedingungen aktualisiert",
|
|
'title' => 'Terms & Conditions aktualisiert',
|
|
'icon' => '📄',
|
|
'message' => 'Wir haben unsere Nutzungsbedingungen aktualisiert.',
|
|
'cta' => ['label' => 'Jetzt lesen', 'url' => url('/legal/terms')],
|
|
],
|
|
'cookie_policy_updated' => [
|
|
'subject' => "{$app}: Cookie-Richtlinie aktualisiert",
|
|
'title' => 'Cookie Policy aktualisiert',
|
|
'icon' => '🍪',
|
|
'message' => 'Wir haben unsere Cookie-Richtlinie aktualisiert.',
|
|
'cta' => ['label' => 'Details ansehen', 'url' => url('/legal/cookies')],
|
|
],
|
|
'privacy_policy_updated' => [
|
|
'subject' => "{$app}: Datenschutz aktualisiert",
|
|
'title' => 'Privacy Policy aktualisiert',
|
|
'icon' => '🔏',
|
|
'message' => 'Wir haben unsere Datenschutzerklärung aktualisiert.',
|
|
'cta' => ['label' => 'Details ansehen', 'url' => url('/legal/privacy')],
|
|
],
|
|
'bonus_policy_updated' => [
|
|
'subject' => "{$app}: Bonus-Richtlinie aktualisiert",
|
|
'title' => 'Bonus Policy aktualisiert',
|
|
'icon' => '🎁',
|
|
'message' => 'Wir haben unsere Bonus-Richtlinie aktualisiert.',
|
|
'cta' => ['label' => 'Details ansehen', 'url' => url('/legal/bonus-policy')],
|
|
],
|
|
'dispute_policy_updated' => [
|
|
'subject' => "{$app}: Streitbeilegung aktualisiert",
|
|
'title' => 'Dispute Resolution aktualisiert',
|
|
'icon' => '⚖️',
|
|
'message' => 'Wir haben unsere Richtlinie zur Streitbeilegung aktualisiert.',
|
|
'cta' => ['label' => 'Details ansehen', 'url' => url('/legal/disputes')],
|
|
],
|
|
'responsible_gaming_updated' => [
|
|
'subject' => "{$app}: Verantwortungsvolles Spielen",
|
|
'title' => 'Responsible Gaming aktualisiert',
|
|
'icon' => '🎯',
|
|
'message' => 'Wir haben unsere Informationen zum verantwortungsvollen Spielen aktualisiert.',
|
|
'cta' => ['label' => 'Mehr erfahren', 'url' => url('/legal/responsible-gaming')],
|
|
],
|
|
'aml_policy_updated' => [
|
|
'subject' => "{$app}: AML-Policy aktualisiert",
|
|
'title' => 'AML Policy aktualisiert',
|
|
'icon' => '🛡️',
|
|
'message' => 'Wir haben unsere AML-Richtlinie aktualisiert.',
|
|
'cta' => ['label' => 'Mehr erfahren', 'url' => url('/legal/aml')],
|
|
],
|
|
'risk_warnings_updated' => [
|
|
'subject' => "{$app}: Risikohinweise aktualisiert",
|
|
'title' => 'Risk Warnings aktualisiert',
|
|
'icon' => '⚠️',
|
|
'message' => 'Wir haben unsere Risikohinweise aktualisiert.',
|
|
'cta' => ['label' => 'Jetzt lesen', 'url' => url('/legal/risk-warnings')],
|
|
],
|
|
|
|
// Support / Misc
|
|
'new_support_message' => [
|
|
'subject' => "{$app}: Neue Support-Nachricht",
|
|
'title' => 'Neue Support-Nachricht',
|
|
'icon' => '💬',
|
|
'message' => 'Du hast eine neue Nachricht von unserem Support-Team erhalten.',
|
|
'cta' => ['label' => 'Support-Chat öffnen', 'url' => url('/support')],
|
|
],
|
|
'casino_updated' => [
|
|
'subject' => "{$app}: Casino aktualisiert",
|
|
'title' => 'Neue Spiele & Updates',
|
|
'icon' => '🎲',
|
|
'message' => 'Es gibt neue Inhalte, Spiele oder Aktionen im Casino. Schau rein! ',
|
|
'cta' => ['label' => 'Jetzt entdecken', 'url' => url('/')],
|
|
],
|
|
];
|
|
}
|
|
|
|
/**
|
|
* Build final data array for the template.
|
|
*
|
|
* @param array<string,mixed> $payload
|
|
* @return array<string,mixed>
|
|
*/
|
|
protected function buildData(string $type, array $payload): array
|
|
{
|
|
$map = $this->map();
|
|
$defaults = $map[$type] ?? [
|
|
'subject' => config('app.name') . ' Notification',
|
|
'title' => Str::headline(str_replace('_', ' ', $type)),
|
|
'icon' => '🔔',
|
|
'message' => 'Es gibt Neuigkeiten zu deinem Konto.',
|
|
];
|
|
|
|
// Merge with payload overrides
|
|
$data = array_merge($defaults, $payload);
|
|
|
|
// Normalize CTA structure
|
|
$cta = $data['cta'] ?? null;
|
|
if (is_string($cta)) {
|
|
$cta = ['label' => 'Open', 'url' => $cta];
|
|
}
|
|
$data['cta'] = is_array($cta) ? $cta : null;
|
|
|
|
// Email 2FA code convenience
|
|
if ($type === 'email_2fa' && empty($data['code']) && !empty($payload['token'])) {
|
|
$data['code'] = (string) $payload['token'];
|
|
}
|
|
|
|
// Allow bullet points list
|
|
if (!empty($data['bullets']) && is_array($data['bullets'])) {
|
|
$data['bullets'] = array_values(array_filter($data['bullets'], fn ($v) => filled($v)));
|
|
}
|
|
|
|
$data['type'] = $type;
|
|
|
|
return $data;
|
|
}
|
|
}
|