referenzen auf "credits" entfernt. Kamera-Seite schicker gemacht
This commit is contained in:
@@ -12,11 +12,18 @@ use App\Models\GuestNotification;
|
||||
use App\Models\GuestNotificationReceipt;
|
||||
use Illuminate\Contracts\Events\Dispatcher;
|
||||
use Illuminate\Support\Arr;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
use Throwable;
|
||||
|
||||
class GuestNotificationService
|
||||
{
|
||||
public function __construct(private readonly Dispatcher $events) {}
|
||||
private bool $notificationsStorageAvailable;
|
||||
|
||||
public function __construct(private readonly Dispatcher $events)
|
||||
{
|
||||
$this->notificationsStorageAvailable = $this->detectStorageAvailability();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array{payload?: array|null, target_identifier?: string|null, priority?: int|null, expires_at?: \DateTimeInterface|null, status?: GuestNotificationState|null, audience_scope?: GuestNotificationAudience|string|null} $options
|
||||
@@ -49,6 +56,12 @@ class GuestNotificationService
|
||||
'expires_at' => $options['expires_at'] ?? null,
|
||||
]);
|
||||
|
||||
if (! $this->notificationsStorageAvailable) {
|
||||
$this->logStorageWarningOnce();
|
||||
|
||||
return $notification;
|
||||
}
|
||||
|
||||
$notification->save();
|
||||
|
||||
$this->events->dispatch(new GuestNotificationCreated($notification));
|
||||
@@ -71,6 +84,16 @@ class GuestNotificationService
|
||||
$guestIdentifier = $this->sanitizeIdentifier($guestIdentifier) ?? 'anonymous';
|
||||
|
||||
/** @var GuestNotificationReceipt $receipt */
|
||||
if (! $this->notificationsStorageAvailable) {
|
||||
$this->logStorageWarningOnce();
|
||||
|
||||
return new GuestNotificationReceipt([
|
||||
'guest_notification_id' => $notification->getKey(),
|
||||
'guest_identifier' => $guestIdentifier,
|
||||
...$this->buildReceiptAttributes($status),
|
||||
]);
|
||||
}
|
||||
|
||||
$receipt = GuestNotificationReceipt::query()->updateOrCreate(
|
||||
[
|
||||
'guest_notification_id' => $notification->getKey(),
|
||||
@@ -159,4 +182,25 @@ class GuestNotificationService
|
||||
return GuestNotificationAudience::ALL;
|
||||
}
|
||||
}
|
||||
|
||||
private function detectStorageAvailability(): bool
|
||||
{
|
||||
try {
|
||||
return Schema::hasTable('guest_notifications') && Schema::hasTable('guest_notification_receipts');
|
||||
} catch (Throwable) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
private function logStorageWarningOnce(): void
|
||||
{
|
||||
static $alreadyWarned = false;
|
||||
|
||||
if ($alreadyWarned) {
|
||||
return;
|
||||
}
|
||||
|
||||
$alreadyWarned = true;
|
||||
Log::warning('Guest notifications storage tables are missing. Notification persistence skipped.');
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user