Files
chatroom/app/Models/User.php
T
lkddi ea06328885 功能:字体颜色持久化、等级体系升级至99级、钓鱼小游戏、补充系统参数
- 字体颜色:s_color 改为 varchar,发消息时保存颜色,进入聊天室自动恢复
- 等级体系:maxlevel 15→99,superlevel 16→100,99级经验阶梯(幂次曲线)
- 管理权限等级按比例调整:禁言50、踢人60、设公告60、封号80、封IP90
- 钓鱼小游戏:FishingController(抛竿扣金币+收竿随机结果+广播)
- 补充6个缺失的 sysparam 参数 + 4个钓鱼参数
- 用户列表点击用户名后自动聚焦输入框
- Pint 格式化
2026-02-26 21:10:34 +08:00

89 lines
2.0 KiB
PHP

<?php
/**
* 文件功能:主用户模型
*
* 对应原 ASP 文件:user 表
*
* @author ChatRoom Laravel
*
* @version 1.0.0
*/
namespace App\Models;
use Illuminate\Database\Eloquent\Casts\Attribute;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Foundation\Auth\User as Authenticatable;
use Illuminate\Notifications\Notifiable;
class User extends Authenticatable
{
use HasFactory, Notifiable;
/**
* The attributes that are mass assignable.
*
* @var array<int, string>
*/
protected $fillable = [
'username',
'password',
'email',
'sex',
'user_level',
'room_id',
'first_ip',
'last_ip',
'usersf',
];
/**
* The attributes that should be hidden for serialization.
*
* @var array<int, string>
*/
protected $hidden = [
'password',
'remember_token',
'temppass',
'ppass',
'userpassword',
];
/**
* Get the attributes that should be cast.
*
* @return array<string, string>
*/
protected function casts(): array
{
return [
'email_verified_at' => 'datetime',
'password' => 'hashed',
'log_time' => 'datetime',
'in_time' => 'datetime',
'out_time' => 'datetime',
'hy_time' => 'datetime',
'xr_time' => 'datetime',
'yx_time' => 'datetime',
'sj' => 'datetime',
'q3_time' => 'datetime',
];
}
/**
* 头像文件名访问器
*
* 原 ASP 系统的头像文件名存储在 usersf 字段中(如 "75.GIF"),
* 但项目中各处通过 $user->headface 来引用头像。
* 此 accessor 将 headface 属性映射到 usersf 字段,保持代码一致性。
*/
protected function headface(): Attribute
{
return Attribute::make(
get: fn () => $this->usersf ?: '1.GIF',
);
}
}