nitpicks
This commit is contained in:
parent
6d32cea614
commit
362ba7d5d8
|
|
@ -57,24 +57,39 @@ class PresenceChannel extends Channel
|
||||||
|
|
||||||
protected function getChannelData(): array
|
protected function getChannelData(): array
|
||||||
{
|
{
|
||||||
$hash = [];
|
|
||||||
foreach ($this->users as $socketId => $channelData) {
|
|
||||||
$hash[$channelData->user_id] = $channelData->user_info;
|
|
||||||
}
|
|
||||||
|
|
||||||
return [
|
return [
|
||||||
'presence' => [
|
'presence' => [
|
||||||
'ids' => array_values(array_map(function($channelData) { return (string)$channelData->user_id; }, $this->users)),
|
'ids' => $this->getUserIds(),
|
||||||
'hash' => $hash,
|
'hash' => $this->getHash(),
|
||||||
'count' => count($this->users)
|
'count' => count($this->users),
|
||||||
]
|
],
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
public function toArray(): array
|
public function toArray(): array
|
||||||
{
|
{
|
||||||
return array_merge(parent::toArray(),[
|
return array_merge(parent::toArray(), [
|
||||||
'user_count' => count($this->users),
|
'user_count' => count($this->users),
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected function getUserIds(): array
|
||||||
|
{
|
||||||
|
$userIds = array_map(function ($channelData) {
|
||||||
|
return (string)$channelData->user_id;
|
||||||
|
}, $this->users);
|
||||||
|
|
||||||
|
return array_values($userIds);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function getHash(): array
|
||||||
|
{
|
||||||
|
$hash = [];
|
||||||
|
|
||||||
|
foreach ($this->users as $socketId => $channelData) {
|
||||||
|
$hash[$channelData->user_id] = $channelData->user_info;
|
||||||
|
}
|
||||||
|
|
||||||
|
return $hash;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
Loading…
Reference in New Issue