$request["content"] ]); $notification->users()->attach($id); return response()->json(['message' => 'Notification created successfully']); } public function getNotifications(Request $request, int $id): JsonResponse { try { $user = User::findOrFail($id); return response()->json([ 'data' => $user->notifications ]); } catch(\Exception $e) { Log::info($e->getMessage()); return response()->json(['message' => "Server error"], 500); } } }