- 字体颜色:s_color 改为 varchar,发消息时保存颜色,进入聊天室自动恢复 - 等级体系:maxlevel 15→99,superlevel 16→100,99级经验阶梯(幂次曲线) - 管理权限等级按比例调整:禁言50、踢人60、设公告60、封号80、封IP90 - 钓鱼小游戏:FishingController(抛竿扣金币+收竿随机结果+广播) - 补充6个缺失的 sysparam 参数 + 4个钓鱼参数 - 用户列表点击用户名后自动聚焦输入框 - Pint 格式化
87 lines
1.7 KiB
PHP
87 lines
1.7 KiB
PHP
<?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',
|
||
'announcement',
|
||
];
|
||
|
||
/**
|
||
* 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');
|
||
}
|
||
}
|