UserSearch.php 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  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 UserSearch
  16. * @package app\model\user
  17. */
  18. class UserSearch 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_search';
  31. /**
  32. * 获取搜索结果
  33. * @param $value
  34. * @return array|mixed
  35. */
  36. public function getResultAttr($value)
  37. {
  38. return json_decode($value, true) ?? [];
  39. }
  40. public function searchUidAttr($query, $value)
  41. {
  42. if ($value !== '') $query->where('uid', $value);
  43. }
  44. public function searchKeywordAttr($query, $value)
  45. {
  46. if ($value !== '') $query->where('keyword', $value);
  47. }
  48. public function searchIsDelAttr($query, $value)
  49. {
  50. if ($value !== '') $query->where('is_del', $value);
  51. }
  52. }