修复在线名单职务图标显示
This commit is contained in:
@@ -2,6 +2,7 @@
|
||||
|
||||
use Illuminate\Support\Facades\Broadcast;
|
||||
|
||||
// 用户私有频道:仅允许用户本人订阅自己的通知频道。
|
||||
Broadcast::channel('App.Models.User.{id}', function ($user, $id) {
|
||||
return (int) $user->id === (int) $id;
|
||||
});
|
||||
@@ -19,6 +20,9 @@ Broadcast::channel('room.{roomId}', function ($user, $roomId) {
|
||||
}
|
||||
|
||||
$superLevel = (int) \App\Models\Sysparam::getValue('superlevel', '100');
|
||||
// 预加载当前在职职务,供右侧在线名单直接显示职务图标与名称。
|
||||
$activePosition = $user->activePosition()->with('position.department')->first();
|
||||
$position = $activePosition?->position;
|
||||
|
||||
return [
|
||||
'id' => $user->id,
|
||||
@@ -30,6 +34,9 @@ Broadcast::channel('room.{roomId}', function ($user, $roomId) {
|
||||
'vip_name' => $user->vipName(),
|
||||
'vip_color' => $user->isVip() ? ($user->vipLevel?->color ?? '') : '',
|
||||
'is_admin' => $user->user_level >= $superLevel,
|
||||
'position_icon' => $position?->icon ?? '',
|
||||
'position_name' => $position?->name ?? '',
|
||||
'department_name' => $position?->department?->name ?? '',
|
||||
];
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user