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')]