From 3ee9bc8e0816ab5a3872d225ef86a26026ef0933 Mon Sep 17 00:00:00 2001 From: Fady Mondy Date: Fri, 14 Jun 2024 01:35:44 +0300 Subject: [PATCH] update user token only if auth --- src/Livewire/Firebase.php | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/Livewire/Firebase.php b/src/Livewire/Firebase.php index 4e88e36..4167c5a 100644 --- a/src/Livewire/Firebase.php +++ b/src/Livewire/Firebase.php @@ -12,11 +12,13 @@ class Firebase extends Component #[On('fcm-token')] public function fcmToken(string $token) { - $user = auth()->user(); - $user->setFCM('fcm-web')->userTokensFcm()->firstOrCreate([ - 'provider' => 'fcm-web', - 'provider_token' => $token - ]); + if(auth()->user()){ + $user = auth()->user(); + $user->setFCM('fcm-web')->userTokensFcm()->firstOrCreate([ + 'provider' => 'fcm-web', + 'provider_token' => $token + ]); + } } #[On('fcm-notification')]