From 464ee6c3c7fa107d3c56e7618f3346b533d9d945 Mon Sep 17 00:00:00 2001 From: dhanabalan Date: Fri, 30 Jan 2026 11:53:23 +0530 Subject: [PATCH] Added web subscription logic in web.php --- routes/web.php | 25 +++++++++++++++++++------ 1 file changed, 19 insertions(+), 6 deletions(-) diff --git a/routes/web.php b/routes/web.php index 8f68667..83ff819 100644 --- a/routes/web.php +++ b/routes/web.php @@ -58,18 +58,31 @@ use App\Http\Livewire\CustomLogin; 'keys.auth' => 'required|string', ]); + // WebPushSubscription::updateOrCreate( + // ['endpoint' => $request->endpoint], + // [ + // 'subscribable_type' => get_class($user), + // 'subscribable_id' => $user->id, + // 'public_key' => $request->keys['p256dh'], + // 'auth_token' => $request->keys['auth'], + // 'content_encoding' => $request->contentEncoding ?? 'aesgcm', + // ] + // ); + WebPushSubscription::updateOrCreate( - // ✅ UNIQUE PER DEVICE - ['endpoint' => $request->endpoint], [ - 'subscribable_type' => get_class($user), // 🔥 important + 'endpoint' => $request->endpoint, + 'subscribable_type' => get_class($user), 'subscribable_id' => $user->id, - 'public_key' => $request->keys['p256dh'], - 'auth_token' => $request->keys['auth'], - 'content_encoding' => $request->contentEncoding ?? 'aesgcm', + ], + [ + 'public_key' => $request->keys['p256dh'], + 'auth_token' => $request->keys['auth'], + 'content_encoding' => $request->contentEncoding ?? 'aesgcm', ] ); + return response()->json(['success' => true]); });