You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
70 lines
1.6 KiB
70 lines
1.6 KiB
<?php
|
|
|
|
namespace app\admin\model\shopro\user;
|
|
|
|
|
|
use app\admin\model\shopro\user\MoneyLog;
|
|
use app\admin\model\shopro\user\ScoreLog;
|
|
use addons\shopro\library\notify\Notifiable;
|
|
use think\Model;
|
|
use think\Db;
|
|
|
|
class User extends Model
|
|
{
|
|
use Notifiable;
|
|
// 表名
|
|
protected $name = 'user';
|
|
// 自动写入时间戳字段
|
|
protected $autoWriteTimestamp = 'int';
|
|
// 定义时间戳字段名
|
|
protected $createTime = 'createtime';
|
|
protected $updateTime = 'updatetime';
|
|
// 追加属性
|
|
protected $append = [
|
|
];
|
|
|
|
public function getGenderList()
|
|
{
|
|
return ['1' => __('Male'), '0' => __('Female')];
|
|
}
|
|
|
|
public function getStatusList()
|
|
{
|
|
return ['normal' => __('Normal'), 'hidden' => __('Hidden')];
|
|
}
|
|
|
|
public function group()
|
|
{
|
|
return $this->belongsTo('Group', 'group_id', 'id', [], 'LEFT')->setEagerlyType(0);
|
|
}
|
|
|
|
public function agent()
|
|
{
|
|
return $this->hasOne(\app\admin\model\shopro\commission\Agent::class, 'user_id', 'id');
|
|
}
|
|
|
|
/**
|
|
* 获取验证字段数组值
|
|
* @param string $value
|
|
* @param array $data
|
|
* @return object
|
|
*/
|
|
public function getVerificationAttr($value, $data)
|
|
{
|
|
$value = array_filter((array)json_decode($value, true));
|
|
$value = array_merge(['email' => 0, 'mobile' => 0], $value);
|
|
return (object)$value;
|
|
}
|
|
|
|
/**
|
|
* 设置验证字段
|
|
* @param mixed $value
|
|
* @return string
|
|
*/
|
|
public function setVerificationAttr($value)
|
|
{
|
|
$value = is_object($value) || is_array($value) ? json_encode($value) : $value;
|
|
return $value;
|
|
}
|
|
|
|
}
|
|
|