44 lines
1011 B
PHP
44 lines
1011 B
PHP
<?php
|
|
|
|
namespace app\common\model;
|
|
|
|
use app\common\model\traits\TimestampInteger;
|
|
use support\think\Model;
|
|
|
|
/**
|
|
* 会员公共模型
|
|
*/
|
|
class User extends Model
|
|
{
|
|
use TimestampInteger;
|
|
|
|
protected string $table = 'user';
|
|
protected string $pk = 'id';
|
|
protected bool $autoWriteTimestamp = true;
|
|
|
|
public function getAvatarAttr($value): string
|
|
{
|
|
return full_url($value, false, config('buildadmin.default_avatar'));
|
|
}
|
|
|
|
public function setAvatarAttr($value): string
|
|
{
|
|
return $value == full_url('', false, config('buildadmin.default_avatar')) ? '' : $value;
|
|
}
|
|
|
|
public function resetPassword($uid, $newPassword)
|
|
{
|
|
return $this->where(['id' => $uid])->update(['password' => hash_password($newPassword), 'salt' => '']);
|
|
}
|
|
|
|
public function getMoneyAttr($value): string
|
|
{
|
|
return bcdiv((string)$value, '100', 2);
|
|
}
|
|
|
|
public function setMoneyAttr($value): string
|
|
{
|
|
return bcmul((string)$value, '100', 2);
|
|
}
|
|
}
|