validate([ 'endpoint' => ['required', 'string', 'url'], 'publicKey' => ['required', 'string'], 'authToken' => ['required', 'string'], ]); PushSubscription::updateOrCreate( [ 'user_id' => Auth::id(), 'endpoint' => $validated['endpoint'], ], [ 'public_key' => $validated['publicKey'], 'auth_token' => $validated['authToken'], ] ); return response()->json(['message' => 'Subscription berhasil disimpan.']); } public function destroy(Request $request): JsonResponse { $validated = $request->validate([ 'endpoint' => ['required', 'string'], ]); PushSubscription::where('user_id', Auth::id()) ->where('endpoint', $validated['endpoint']) ->delete(); return response()->json(['message' => 'Subscription berhasil dihapus.']); } }