- 移除聊天室右下角浮动游戏图标(占卜、百家乐、赛马、老虎机) - 用户名片按钮区:修复已婚/已好友时按钮换行问题,统一单行显示 - 婚礼红包弹窗:重设计为喜庆鲜红背景,领取按钮改为圆形米黄样式 - 新增婚礼红包恢复接口(/wedding/pending-envelopes),刷新后自动恢复领取按钮 - 修复 Alpine :style 字符串覆盖静态 style 导致圆形按钮失效的问题 - 撤职后用户等级改为根据经验值重新计算,不再无条件重置为1 - 管理员修改用户经验值后自动重算等级,有职务用户等级锁定 - 娱乐大厅钓鱼游戏按钮直接调用 startFishing() 简化操作流程 - 新增赛马、占卜、百家乐游戏及相关后端逻辑
68 lines
1.7 KiB
PHP
68 lines
1.7 KiB
PHP
<?php
|
||
|
||
/**
|
||
* 文件功能:赛马开赛广播事件
|
||
*
|
||
* 新场次开始押注时广播给房间所有用户,携带场次 ID、
|
||
* 参赛马匹信息和押注截止时间,前端展示倒计时押注面板。
|
||
*
|
||
* @author ChatRoom Laravel
|
||
*
|
||
* @version 1.0.0
|
||
*/
|
||
|
||
namespace App\Events;
|
||
|
||
use App\Models\HorseRace;
|
||
use Illuminate\Broadcasting\InteractsWithSockets;
|
||
use Illuminate\Broadcasting\PresenceChannel;
|
||
use Illuminate\Contracts\Broadcasting\ShouldBroadcastNow;
|
||
use Illuminate\Foundation\Events\Dispatchable;
|
||
use Illuminate\Queue\SerializesModels;
|
||
|
||
class HorseRaceOpened implements ShouldBroadcastNow
|
||
{
|
||
use Dispatchable, InteractsWithSockets, SerializesModels;
|
||
|
||
/**
|
||
* @param HorseRace $race 本场信息
|
||
*/
|
||
public function __construct(
|
||
public readonly HorseRace $race,
|
||
) {}
|
||
|
||
/**
|
||
* 广播至房间公共频道。
|
||
*
|
||
* @return array<\Illuminate\Broadcasting\Channel>
|
||
*/
|
||
public function broadcastOn(): array
|
||
{
|
||
return [new PresenceChannel('room.1')];
|
||
}
|
||
|
||
/**
|
||
* 广播事件名(前端监听 .horse.opened)。
|
||
*/
|
||
public function broadcastAs(): string
|
||
{
|
||
return 'horse.opened';
|
||
}
|
||
|
||
/**
|
||
* 广播数据。
|
||
*
|
||
* @return array<string, mixed>
|
||
*/
|
||
public function broadcastWith(): array
|
||
{
|
||
return [
|
||
'race_id' => $this->race->id,
|
||
'horses' => $this->race->horses,
|
||
'bet_opens_at' => $this->race->bet_opens_at->toIso8601String(),
|
||
'bet_closes_at' => $this->race->bet_closes_at->toIso8601String(),
|
||
'bet_seconds' => (int) now()->diffInSeconds($this->race->bet_closes_at),
|
||
];
|
||
}
|
||
}
|