UserFriends.php 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. <?php
  2. // +----------------------------------------------------------------------
  3. // | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
  4. // +----------------------------------------------------------------------
  5. // | Copyright (c) 2016~2023 https://www.crmeb.com All rights reserved.
  6. // +----------------------------------------------------------------------
  7. // | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权
  8. // +----------------------------------------------------------------------
  9. // | Author: CRMEB Team <admin@crmeb.com>
  10. // +----------------------------------------------------------------------
  11. namespace app\model\user;
  12. use crmeb\basic\BaseModel;
  13. use crmeb\traits\ModelTrait;
  14. use think\Model;
  15. class UserFriends extends BaseModel
  16. {
  17. use ModelTrait;
  18. /**
  19. * 表明
  20. * @var string
  21. */
  22. protected $name = 'user_friends';
  23. /**
  24. * 主键
  25. * @var string
  26. */
  27. protected $pk = 'id';
  28. /**
  29. *
  30. * @return \think\model\relation\HasOne
  31. */
  32. public function level()
  33. {
  34. return $this->hasOne(User::class, 'uid', 'uid')->field(['uid', 'level'])->bind([
  35. 'level' => 'level'
  36. ]);
  37. }
  38. /**
  39. * @return \think\model\relation\HasOne
  40. */
  41. public function nickname()
  42. {
  43. return $this->hasOne(User::class, 'uid', 'uid')->field(['uid', 'nickname'])->bind([
  44. 'nickname' => 'nickname'
  45. ]);
  46. }
  47. /**
  48. * uid搜索器
  49. * @param Model $query
  50. * @param $value
  51. */
  52. public function searchUidAttr($query, $value)
  53. {
  54. $query->where('uid', $value);
  55. }
  56. /**
  57. * 修改添加时间
  58. * @param $value
  59. * @return false|string
  60. */
  61. public function getAddTimeAttr($value)
  62. {
  63. return date('Y-m-d H:i:s', $value);
  64. }
  65. }