Files
chatroom/routes/channels.php
lkddi bfd90ca882 统一:所有图片后缀从 .GIF 改为 .gif
- headface 目录 371 个文件重命名为小写后缀
- 代码中所有 .GIF 引用改为 .gif(User.php/AuthController/channels.php/frame.blade/scripts.blade)
- 新增迁移:将 users 表 usersf 列中的 .GIF 批量替换为 .gif
- 解决 Linux 大小写敏感导致图片加载失败的问题
2026-02-26 23:27:35 +08:00

29 lines
1.1 KiB
PHP
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<?php
use Illuminate\Support\Facades\Broadcast;
Broadcast::channel('App.Models.User.{id}', function ($user, $id) {
return (int) $user->id === (int) $id;
});
// 聊天室房间 Presence Channel 鉴权与成员信息抓取
Broadcast::channel('room.{roomId}', function ($user, $roomId) {
// 这里未来可以增加判断:比如该房间是否被锁定,或者该用户是否在此房间的黑名单中
// 凡是通过了这个判断的人(返回一个数组),他就会成功建立 WebSocket
// 且他的这个数组信息会被 Reverb 推送给这个房间内的所有其他人 (joining / here 事件)。
$superLevel = (int) \App\Models\Sysparam::getValue('superlevel', '100');
return [
'id' => $user->id,
'username' => $user->username,
'user_level' => $user->user_level,
'sex' => $user->sex,
'headface' => $user->headface, // 通过 accessor 读取 usersf默认 1.gif
'vip_icon' => $user->vipIcon(),
'vip_name' => $user->vipName(),
'vip_color' => $user->isVip() ? ($user->vipLevel?->color ?? '') : '',
'is_admin' => $user->user_level >= $superLevel,
];
});