notifications, $this->unreadCount); } /** * Only unread — once a notification is read (clicked through, or via * "mark all as read"), it disappears from the bell rather than staying * listed dimmed. The full history still lives in the notifications * table for anyone querying it directly, just not surfaced here. */ #[Computed] public function notifications() { return Auth::user()->unreadNotifications()->latest()->limit(20)->get(); } #[Computed] public function unreadCount(): int { return Auth::user()->unreadNotifications()->count(); } public function markAsRead(string $id): void { Auth::user()->notifications()->where('id', $id)->first()?->markAsRead(); unset($this->notifications, $this->unreadCount); } public function markAllAsRead(): void { Auth::user()->unreadNotifications->each->markAsRead(); unset($this->notifications, $this->unreadCount); } public function render() { return view('livewire.notification-bell'); } }