34 lines
1.1 KiB
PHP
34 lines
1.1 KiB
PHP
<?php
|
|
|
|
/*
|
|
|--------------------------------------------------------------------------
|
|
| Broadcast Channels
|
|
|--------------------------------------------------------------------------
|
|
|
|
|
| Here you may register all of the event broadcasting channels that your
|
|
| application supports. The given channel authorization callbacks are
|
|
| used to check if an authenticated user can listen to the channel.
|
|
|
|
|
*/
|
|
|
|
Broadcast::channel('App.User.{id}', function ($user, $id) {
|
|
return (int) $user->id === (int) $id;
|
|
});
|
|
|
|
Broadcast::channel('business.{businessId}.chat.{roomId}', function ($user, $businessId, $roomId) {
|
|
if ((int) $user->business_id !== (int) $businessId) {
|
|
return false;
|
|
}
|
|
|
|
return \Modules\Communication\Entities\ChatRoom::where('business_id', $businessId)
|
|
->where('id', $roomId)
|
|
->whereHas('members', function ($q) use ($user) {
|
|
$q->where('users.id', $user->id);
|
|
})
|
|
->exists();
|
|
});
|
|
|
|
Broadcast::channel('business.{businessId}.user.{targetUserId}', function ($user, $businessId, $targetUserId) {
|
|
return (int) $user->business_id === (int) $businessId && (int) $user->id === (int) $targetUserId;
|
|
});
|