UserCancel.php 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  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. /**
  15. * Class UserCancel
  16. * @package app\model\user
  17. */
  18. class UserCancel extends BaseModel
  19. {
  20. use ModelTrait;
  21. /**
  22. * 数据表主键
  23. * @var string
  24. */
  25. protected $pk = 'id';
  26. /**
  27. * 模型名称
  28. * @var string
  29. */
  30. protected $name = 'user_cancel';
  31. /**
  32. * 关联用户表
  33. * @return \think\model\relation\HasOne
  34. */
  35. public function user()
  36. {
  37. return $this->hasOne(User::class, 'uid', 'uid')->bind([
  38. 'money' => 'now_money',
  39. 'brokerage' => 'brokerage_price'
  40. ]);
  41. }
  42. /**
  43. * 状态搜索器
  44. * @param $query
  45. * @param $value
  46. */
  47. public function searchStatusAttr($query, $value)
  48. {
  49. if ($value !== '') {
  50. $query->where('status', $value);
  51. }
  52. }
  53. /**
  54. * 关键字搜索器
  55. * @param $query
  56. * @param $value
  57. */
  58. public function searchKeywordsAttr($query, $value)
  59. {
  60. if ($value !== '') {
  61. $query->where('uid|name|phone', 'like', '%' . $value . '%');
  62. }
  63. }
  64. }