<?php

use Illuminate\Support\Facades\Broadcast;
use App\Models\Conversation;

Broadcast::channel('chat.{conversationId}', function ($user, $conversationId) {
    $conversation = Conversation::find($conversationId);
    return $conversation && ($user->id === $conversation->buyer_id || $user->id === $conversation->seller_id);
});

// --- Global User Channel for Header Badges (Chat Messages) ---
Broadcast::channel('user.{id}', function ($user, $id) {
    return (int) $user->id === (int) $id;
});

// --- Laravel Default Notification Channel (Bell Icon Popover) ---
Broadcast::channel('App.Models.User.{id}', function ($user, $id) {
    return (int) $user->id === (int) $id;
});