<?php

use Illuminate\Support\Facades\Broadcast;

/*
| Each authenticated user gets a private channel for their own notifications.
| Server / website / incident streams broadcast on shared channels gated by role.
*/
Broadcast::channel('user.{userId}', function ($user, $userId) {
    return (int) $user->id === (int) $userId;
});

Broadcast::channel('servers', function ($user) {
    return $user->status === 'active';
});

Broadcast::channel('incidents', function ($user) {
    return $user->status === 'active';
});

Broadcast::channel('metrics.{serverId}', function ($user, $serverId) {
    return $user->status === 'active';
});
