AgentLevel.php 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  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. declare (strict_types=1);
  12. namespace app\model\agent;
  13. use crmeb\basic\BaseModel;
  14. use crmeb\traits\ModelTrait;
  15. use think\Model;
  16. /**
  17. * 分销员等级
  18. * Class AgentLevel
  19. * @package app\model\agent
  20. */
  21. class AgentLevel extends BaseModel
  22. {
  23. use ModelTrait;
  24. /**
  25. * 数据表主键
  26. * @var string
  27. */
  28. protected $pk = 'id';
  29. /**
  30. * 模型名称
  31. * @var string
  32. */
  33. protected $name = 'agent_level';
  34. /**
  35. * 关联等级任务
  36. * @return \think\model\relation\HasMany
  37. */
  38. public function task()
  39. {
  40. return $this->hasMany(AgentLevelTask::class, 'level_id', 'id')->where('is_del', 0);
  41. }
  42. /**
  43. * 关键词搜索
  44. * @param $query
  45. * @param $value
  46. */
  47. public function searchKeywordAttr($query, $value)
  48. {
  49. if ($value !== '') $query->whereLike('id|name', "%" . trim($value) . "%");
  50. }
  51. /**
  52. * 等级搜索器
  53. * @param $query Model
  54. * @param $value
  55. */
  56. public function searchGradeAttr($query, $value)
  57. {
  58. if ($value !== '') $query->where('grade', $value);
  59. }
  60. /**
  61. * 状态搜索器
  62. * @param $query Model
  63. * @param $value
  64. */
  65. public function searchStatusAttr($query, $value)
  66. {
  67. if ($value !== '') $query->where('status', $value);
  68. }
  69. /**
  70. * 是否删除搜索器
  71. * @param $query Model
  72. * @param $value
  73. */
  74. public function searchIsDelAttr($query, $value)
  75. {
  76. if ($value !== '') $query->where('is_del', $value);
  77. }
  78. }