Browse Source

complete socket notification channel

mohammad
mahdihty 4 years ago
parent
commit
d264fe0bc9
  1. 3
      app/Channels/SocketChannel.php
  2. 10
      app/Models/User.php

3
app/Channels/SocketChannel.php

@ -46,7 +46,6 @@ class SocketChannel
$message = $notification->toSocket($notifiable);
$message->to($notifiable->routeNotificationFor('socket', $notification));
$message->to('1');
if (! $message->to) {
return;
@ -56,7 +55,7 @@ class SocketChannel
'headers' => [
'Content-Type' => 'application/json',
],
'data' => [$message->data],
'json' => ['data' => $message->data],
]);
}
}

10
app/Models/User.php

@ -50,6 +50,16 @@ class User extends Model implements AuthenticatableContract, AuthorizableContrac
return $this->fingerprints->whereNotNull('fcm_token')->pluck('fcm_token')->all();
}
/**
* Specifies the user's Socket room
*
* @return string
*/
public function routeNotificationForSocket()
{
return request('_business_info')['id'] ?? null;
}
public function updateRelations()
{
// projects relations

Loading…
Cancel
Save