UserLabelCate.php 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  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 think\Model;
  14. /**
  15. * Class UserLabelCate
  16. * @package app\model\user
  17. */
  18. class UserLabelCate extends BaseModel
  19. {
  20. /**
  21. * 表名
  22. * @var string
  23. */
  24. protected $name = 'user_label_cate';
  25. /**
  26. * 主键
  27. * @var string
  28. */
  29. protected $pk = 'id';
  30. /**
  31. * @param Model $query
  32. * @param $value
  33. */
  34. public function searchNameAttr($query, $value)
  35. {
  36. $query->whereLike('name', '%' . $value . '%');
  37. }
  38. /**
  39. * 一对多关联
  40. * @return \think\model\relation\HasMany
  41. */
  42. public function label()
  43. {
  44. return $this->hasMany(UserLabel::class, 'label_cate', 'id');
  45. }
  46. }