Files
chatroom/app/Models/Room.php
lkddi d884853968 修复:排行榜/留言板缺失布局、退出登录跳转、WebSocket 配置与部署文档
- 修复 LeaderboardController 查询不存在的 sign 字段导致 500 错误
- 修复 leaderboard/index 和 guestbook/index 引用不存在的 layouts.app 布局
- 将排行榜和留言板改为独立 HTML 页面结构(含 Tailwind CDN)
- 修复退出登录返回 JSON 而非重定向的问题,现在会正确跳转回登录页
- 将 REDIS_CLIENT 从 phpredis 改为 predis(兼容无扩展环境)
- 新增 RoomSeeder 自动创建默认公共大厅房间
- 新增 Nginx 生产环境配置示例(含 WebSocket 反向代理)
- 重写 README.md 为完整的中文部署指南
- 修复 rooms/index 和 chat/frame 中 Alpine.js 语法错误
- 将 chat.js 加入 Vite 构建配置
- 新增验证码配置文件
2026-02-26 14:57:24 +08:00

86 lines
1.7 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
/**
* 文件功能:聊天房间模型
*
* 对应原 ASP 文件room 表
*
* @author ChatRoom Laravel
*
* @version 1.0.0
*/
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
class Room extends Model
{
/**
* The attributes that are mass assignable.
*
* @var array<int, string>
*/
protected $fillable = [
'room_name',
'room_auto',
'room_owner',
'room_des',
'room_top',
'room_title',
'room_keep',
'room_time',
'room_tt',
'room_html',
'room_exp',
'build_time',
'permit_level',
'door_open',
];
/**
* Get the attributes that should be cast.
*
* @return array<string, string>
*/
protected function casts(): array
{
return [
'room_time' => 'datetime',
'build_time' => 'datetime',
'room_keep' => 'boolean',
'room_tt' => 'boolean',
'room_html' => 'boolean',
'door_open' => 'boolean',
];
}
// ---- 兼容新版逻辑和 Blade 视图的访问器 ----
public function getNameAttribute(): string
{
return $this->room_name ?? '';
}
public function getDescriptionAttribute(): string
{
return $this->room_des ?? '';
}
public function getMasterAttribute(): string
{
return $this->room_owner ?? '';
}
public function getIsSystemAttribute(): bool
{
return (bool) $this->room_keep;
}
// 同样可为主讲人关联提供便捷方法
public function masterUser()
{
return $this->belongsTo(User::class, 'room_owner', 'username');
}
}