UserModel.php 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. <?php
  2. // +----------------------------------------------------------------------
  3. // | ThinkCMF [ WE CAN DO IT MORE SIMPLE ]
  4. // +----------------------------------------------------------------------
  5. // | Copyright (c) 2013-2017 http://www.thinkcmf.com All rights reserved.
  6. // +----------------------------------------------------------------------
  7. // | Author: pl125 <xskjs888@163.com>
  8. // +----------------------------------------------------------------------
  9. namespace api\portal\model;
  10. use think\Model;
  11. class UserModel extends Model
  12. {
  13. /**
  14. * 模型名称
  15. * @var string
  16. */
  17. protected $name = 'user';
  18. //模型关联方法
  19. protected $relationFilter = ['user'];
  20. /**
  21. * more 自动转化
  22. * @param $value
  23. * @return string
  24. */
  25. public function getAvatarAttr($value)
  26. {
  27. $value = !empty($value) ? cmf_get_image_url($value) : $value;
  28. return $value;
  29. }
  30. /**
  31. * 关联 user表
  32. * @return string 关联数据
  33. */
  34. public function user()
  35. {
  36. return $this->belongsTo('UserModel', 'user_id')->setEagerlyType(1);
  37. }
  38. }