1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556 |
- <?php
-
-
- namespace app\model\user\label;
-
- use crmeb\basic\BaseModel;
- use crmeb\traits\ModelTrait;
- use think\Model;
-
- /**
- * 用户关联标签
- * Class UserLabelRelation
- * @package app\model\user\label
- */
- class UserLabelRelation extends BaseModel
- {
- use ModelTrait;
-
- /**
- * 模型名称
- * @var string
- */
- protected $name = 'user_label_relation';
-
- /**
- * @return \think\model\relation\HasOne
- */
- public function label()
- {
- return $this->hasOne(UserLabel::class, 'id', 'label_id')->bind([
- 'label_name' => 'label_name'
- ]);
- }
-
- /**
- * uid搜索器
- * @param Model $query
- * @param $value
- */
- public function searchUidAttr($query, $value)
- {
- $query->whereIn('uid', $value);
- }
-
- /**
- * 门店id搜索器
- * @param $query
- * @param $value
- */
- public function searchStoreIdAttr($query, $value)
- {
- if ($value !== '') {
- $query->where('store_id', $value);
- }
- }
- }
|