middleware('auth'); } public function index(NotificationService $notifications) { return response()->json($notifications->inboxPayload(Auth::user())); } public function markAsRead(NotificationService $notifications, $id) { $notification = $notifications->markAsRead(Auth::user(), $id); if (!$notification) { return response()->json(['message' => 'Notifikasi tidak dijumpai.'], 404); } return response()->json([ 'notification' => $notification->toInboxArray(), 'unread_count' => $notifications->unreadCount(Auth::user()), ]); } public function markAllAsRead(NotificationService $notifications) { $updated = $notifications->markAllAsRead(Auth::user()); return response()->json([ 'updated' => $updated, 'unread_count' => 0, ]); } }