UserModel.php 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  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. protected $relationFilter = ['user'];
  15. /**
  16. * more 自动转化
  17. * @param $value
  18. * @return string
  19. */
  20. public function getAvatarAttr($value)
  21. {
  22. $value = !empty($value) ? cmf_get_image_url($value) : $value;
  23. return $value;
  24. }
  25. /**
  26. * 关联 user表
  27. * @return string 关联数据
  28. */
  29. public function user()
  30. {
  31. return $this->belongsTo('UserModel', 'user_id')->setEagerlyType(1);
  32. }
  33. }