1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071 |
- <?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;
- }
-
- }
|