user() ->notifications() ->latest() ->get(); return response()->json(['data' => $notifications]); } catch (\Exception $e) { Log::error($e->getMessage()); return response()->json(['message' => 'Server error'], 500); } } public function deleteNotification(Request $request, int $notificationId): JsonResponse { try { $notification = $request->user()->notifications()->findOrFail($notificationId); $notification->delete(); return response()->json(['message' => 'Notification supprimée avec succès']); } catch (\Exception $e) { Log::error($e->getMessage()); return response()->json(['message' => 'Erreur lors de la suppression'], 500); } } public function readNotifications(Request $request): JsonResponse { try { $request->user()->unreadNotifications->markAsRead(); return response()->json(['message' => 'Notifications marquées comme lues']); } catch (\Exception $e) { Log::error($e->getMessage()); return response()->json(['message' => 'Server error'], 500); } } }