| xqd
@@ -23,7 +23,7 @@ class AgentWhere extends Criteria {
|
|
|
* @param array $search
|
|
|
*
|
|
|
*/
|
|
|
- public function __construct(array $search,int $store_id)
|
|
|
+ public function __construct(array $search, int $store_id)
|
|
|
{
|
|
|
$this->search = $search;
|
|
|
$this->store_id = $store_id;
|
| xqd
@@ -36,17 +36,30 @@ class AgentWhere extends Criteria {
|
|
|
*/
|
|
|
public function apply($model, Repository $repository)
|
|
|
{
|
|
|
- if(isset($this->search['keyword']) && $this->search['keyword']) {
|
|
|
- $keyword = '%'.$this->search['keyword'].'%';
|
|
|
+ if (isset($this->search['keyword']) && $this->search['keyword']) {
|
|
|
+ $keyword = '%' . $this->search['keyword'] . '%';
|
|
|
$model = $model->where([['name','like',$keyword],['store_id',$this->store_id]])
|
|
|
->orwhere([['id','like',$keyword],['store_id',$this->store_id]])
|
|
|
->orwhere([['address','like',$keyword],['store_id',$this->store_id]])
|
|
|
->orwhere([['phone','like',$keyword],['store_id',$this->store_id]]);
|
|
|
- } else if(isset($this->search['updated_at']) && $this->search['updated_at']) {
|
|
|
- $model = $model->where('updated_at',$this->search['updated_at']);
|
|
|
} else {
|
|
|
- $model = $model->where([['store_id',$this->store_id]]);
|
|
|
+ $model = $model->where([['store_id', $this->store_id]]);
|
|
|
}
|
|
|
+ if (isset($this->search['status']) && $this->search['status']) {
|
|
|
+ $status = $this->search['status'];
|
|
|
+ $model = $model->whereHas('user', function ($model) use ($status) {
|
|
|
+ if ($status == 3) {
|
|
|
+ $model->where('is_boss', 1);
|
|
|
+ }
|
|
|
+ })->with(['a:nickname,a:is_boss']);
|
|
|
+ if ($status == 2) {
|
|
|
+ $model = $model->where([['status', 1]]);
|
|
|
+ }
|
|
|
+ if ($status == 1) {
|
|
|
+ $model = $model->where([['status', 0]]);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
|
|
|
return $model;
|
|
|
}
|