您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

UserLabelRelation.php 1022B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. <?php
  2. namespace app\model\user\label;
  3. use crmeb\basic\BaseModel;
  4. use crmeb\traits\ModelTrait;
  5. use think\Model;
  6. /**
  7. * 用户关联标签
  8. * Class UserLabelRelation
  9. * @package app\model\user\label
  10. */
  11. class UserLabelRelation extends BaseModel
  12. {
  13. use ModelTrait;
  14. /**
  15. * 模型名称
  16. * @var string
  17. */
  18. protected $name = 'user_label_relation';
  19. /**
  20. * @return \think\model\relation\HasOne
  21. */
  22. public function label()
  23. {
  24. return $this->hasOne(UserLabel::class, 'id', 'label_id')->bind([
  25. 'label_name' => 'label_name'
  26. ]);
  27. }
  28. /**
  29. * uid搜索器
  30. * @param Model $query
  31. * @param $value
  32. */
  33. public function searchUidAttr($query, $value)
  34. {
  35. $query->whereIn('uid', $value);
  36. }
  37. /**
  38. * 门店id搜索器
  39. * @param $query
  40. * @param $value
  41. */
  42. public function searchStoreIdAttr($query, $value)
  43. {
  44. if ($value !== '') {
  45. $query->where('store_id', $value);
  46. }
  47. }
  48. }