Files
chatroom/app/Models/User.php

89 lines
2.0 KiB
PHP
Raw Normal View History

2026-02-26 12:02:00 +08:00
<?php
/**
* 文件功能:主用户模型
*
* 对应原 ASP 文件user
*
* @author ChatRoom Laravel
*
* @version 1.0.0
*/
2026-02-26 12:02:00 +08:00
namespace App\Models;
use Illuminate\Database\Eloquent\Casts\Attribute;
2026-02-26 12:02:00 +08:00
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>
2026-02-26 12:02:00 +08:00
*/
protected $fillable = [
'username',
2026-02-26 12:02:00 +08:00
'password',
'email',
'sex',
'user_level',
'room_id',
'first_ip',
'last_ip',
'usersf',
2026-02-26 12:02:00 +08:00
];
/**
* The attributes that should be hidden for serialization.
*
* @var array<int, string>
2026-02-26 12:02:00 +08:00
*/
protected $hidden = [
'password',
'remember_token',
'temppass',
'ppass',
'userpassword',
2026-02-26 12:02:00 +08:00
];
/**
* 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',
2026-02-26 12:02:00 +08:00
];
}
/**
* 头像文件名访问器
*
* ASP 系统的头像文件名存储在 usersf 字段中(如 "75.GIF"
* 但项目中各处通过 $user->headface 来引用头像。
* accessor headface 属性映射到 usersf 字段,保持代码一致性。
*/
protected function headface(): Attribute
{
return Attribute::make(
get: fn () => $this->usersf ?: '1.GIF',
);
}
2026-02-26 12:02:00 +08:00
}