notify(new PortalNotification('Beitrag freigegeben', '„Sommerfest“ ist online.', '/neuigkeiten/sommerfest', 'check')); */ class PortalNotification extends Notification { use Queueable; public function __construct( public readonly string $title, public readonly string $body = '', public readonly ?string $url = null, public readonly string $icon = 'bell', ) {} /** * @return list */ public function via(object $notifiable): array { // Zusätzlich als Push auf Geräte, die das eingeschaltet haben $push = $notifiable instanceof User && PushSubscription::query()->where('user_id', $notifiable->id)->exists(); return $push ? ['database', WebPushChannel::class] : ['database']; } /** * @return array */ public function toArray(object $notifiable): array { return ['title' => $this->title, 'body' => $this->body, 'url' => $this->url, 'icon' => $this->icon]; } }