- 新建 AdminCommandController 处理6个管理操作命令
- 注册管理员命令路由 /command/*
- 更新 UserKicked 事件增加原因字段
- 更新 UserMuted 事件支持自定义提示消息
- 重构用户名片弹窗管理面板:警告/踢出/禁言/冻结按钮
- 站长专属:查看私信记录、📢公屏讲话按钮
- 被踢出时显示踢出原因
63 lines
1.4 KiB
PHP
63 lines
1.4 KiB
PHP
<?php
|
|
|
|
/**
|
|
* 文件功能:用户被踢出房间广播事件
|
|
*
|
|
* 管理员踢出/冻结用户时触发,前端监听后强制该用户跳转至大厅。
|
|
*
|
|
* @author ChatRoom Laravel
|
|
*
|
|
* @version 1.0.0
|
|
*/
|
|
|
|
namespace App\Events;
|
|
|
|
use Illuminate\Broadcasting\InteractsWithSockets;
|
|
use Illuminate\Broadcasting\PresenceChannel;
|
|
use Illuminate\Contracts\Broadcasting\ShouldBroadcast;
|
|
use Illuminate\Foundation\Events\Dispatchable;
|
|
use Illuminate\Queue\SerializesModels;
|
|
|
|
class UserKicked implements ShouldBroadcast
|
|
{
|
|
use Dispatchable, InteractsWithSockets, SerializesModels;
|
|
|
|
/**
|
|
* 构造函数
|
|
*
|
|
* @param int $roomId 房间ID
|
|
* @param string $username 被踢出的用户昵称
|
|
* @param string $reason 踢出原因
|
|
*/
|
|
public function __construct(
|
|
public readonly int $roomId,
|
|
public readonly string $username,
|
|
public readonly string $reason = '',
|
|
) {}
|
|
|
|
/**
|
|
* 广播频道
|
|
*
|
|
* @return array<int, \Illuminate\Broadcasting\Channel>
|
|
*/
|
|
public function broadcastOn(): array
|
|
{
|
|
return [
|
|
new PresenceChannel('room.'.$this->roomId),
|
|
];
|
|
}
|
|
|
|
/**
|
|
* 广播数据
|
|
*
|
|
* @return array<string, mixed>
|
|
*/
|
|
public function broadcastWith(): array
|
|
{
|
|
return [
|
|
'username' => $this->username,
|
|
'reason' => $this->reason,
|
|
];
|
|
}
|
|
}
|