UserAuths.php 789 B

12345678910111213141516171819202122232425262728293031323334353637
  1. <?php
  2. namespace app\common\model;
  3. use think\Model;
  4. class UserAuths extends Model
  5. {
  6. // 设置字段信息
  7. protected $schema = [
  8. 'id' => 'int',
  9. 'userid' => 'int',
  10. 'identitytype' => 'string',
  11. 'identifier' => 'string',
  12. 'password' => 'string',
  13. 'logintime' => 'int',
  14. 'loginip' => 'string'
  15. ];
  16. // 设置字段自动转换类型
  17. protected $type = [
  18. 'logintime' => 'timestamp:Y-m-d H:i:s'
  19. ];
  20. public function getIdentitytypeTextAttr($value,$data)
  21. {
  22. $identitytype = ['mobile'=>'手机号', 'email'=>'邮箱', 'qq'=>'QQ', 'weixin'=>'微信', 'weibo'=>'微博'];
  23. return $identitytype[$data['identitytype']];
  24. }
  25. // 相对关联User
  26. public function user()
  27. {
  28. return $this->hasOne(User::class, "id", "userid");
  29. }
  30. }