123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106 |
- <?php
- namespace app\model\store;
- use app\model\user\User;
- use crmeb\basic\BaseModel;
- use crmeb\traits\ModelTrait;
- use think\Model;
- class StoreUser extends BaseModel
- {
- use ModelTrait;
-
- protected $pk = 'id';
-
- protected $name = 'store_user';
-
- public function user()
- {
- return $this->hasOne(User::class, 'uid', 'uid');
- }
-
- public function searchStoreIdAttr($query, $value)
- {
- if ($value && $value != -1) {
- $query->where('store_id', $value);
- }
- }
-
- protected function setLabelIdAttr($value)
- {
- if ($value) {
- return is_array($value) ? implode(',', $value) : $value;
- }
- return '';
- }
-
- protected function getLabelIdAttr($value)
- {
- if ($value) {
- return is_string($value) ? explode(',', $value) : $value;
- }
- return [];
- }
-
- public function searchUidAttr($query, $value)
- {
- if (is_array($value)) {
- $query->whereIn('uid', $value);
- } else {
- if ($value) {
- $query->where('uid', $value);
- }
- }
- }
- }
|