Skip to content

Commit

Permalink
update user token only if auth
Browse files Browse the repository at this point in the history
  • Loading branch information
3x1io committed Jun 13, 2024
1 parent 9598b2e commit 3ee9bc8
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions src/Livewire/Firebase.php
Original file line number Diff line number Diff line change
Expand Up @@ -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')]
Expand Down

0 comments on commit 3ee9bc8

Please sign in to comment.