Files
orico-official-website/app/admin/model/v1/UserModel.php
2024-12-31 18:05:36 +08:00

44 lines
959 B
PHP

<?php
declare (strict_types = 1);
namespace app\admin\model\v1;
use think\Model;
/**
* @mixin \think\Model
*/
class UserModel extends Model
{
// 表名
protected $name = 'sys_user';
// 主键
protected $pk = 'id';
// 隐藏字段
protected $hidden = ['password', 'salt'];
// 字段信息
protected $schema = [
'id' => 'int',
'username' => 'string',
'password' => 'string',
'salt' => 'string',
'role_id' => 'int',
'nickname' => 'string',
'avatar' => 'string',
'mobile' => 'string',
'email' => 'string',
'status' => 'int',
'created_at' => 'datetime',
'updated_at' => 'datetime',
] ;
// 用户名查询范围
public function scopeUsernameOrMobile($query, $username)
{
return $query->where('username', '=', $username)->whereOr('mobile', '=', $username);
}
}