diff --git a/app/Channels/SocketChannel.php b/app/Channels/SocketChannel.php index 51af1a8..967475c 100644 --- a/app/Channels/SocketChannel.php +++ b/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], ]); } } diff --git a/app/Models/User.php b/app/Models/User.php index 016aebf..ea04af2 100644 --- a/app/Models/User.php +++ b/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