request = $request; } /** * @param $model * @param RepositoryInterface $repository * * @return mixed */ public function apply($model, RepositoryInterface $repository) { if ($this->request->filled('user_id')) { $val = $this->request->get('user_id'); $model = $model->where('user_id', '=', $val); } if ($this->request->filled('user_mobile')) { $val = $this->request->get('user_mobile'); $ids = User::byMobileGetIds($val); $model = $model->whereIn('user_id', $ids); } if ($this->request->filled('user_nickname')) { $val = $this->request->get('user_nickname'); $model = $model->whereHas('user', function ($query) use ($val) { return $query->where('nickname', 'like', "%{$val}%"); }); } if ($this->request->filled('name')) { $val = $this->request->get('name'); $model = $model->where('name', 'like', "%{$val}%"); } if ($this->request->filled('name')) { $val = $this->request->get('name'); $model = $model->where('name', 'like', "%{$val}%"); } if ($this->request->filled('province')) { $val = $this->request->get('province'); $model = $model->where('province', 'like', "%{$val}%"); } if ($this->request->filled('city')) { $val = $this->request->get('city'); $model = $model->where('city', 'like', "%{$val}%"); } if ($this->request->filled('area')) { $val = $this->request->get('area'); $model = $model->where('area', 'like', "%{$val}%"); } if ($this->request->filled('address')) { $val = $this->request->get('address'); $model = $model->where('address', 'like', "%{$val}%"); } if ($this->request->filled('status')) { $status = $this->request->get('status'); $model = $model->where('status', '=', $status); } if ($this->request->filled('ids')) { $ids = $this->request->get('ids'); $model = $model->whereIn('id', $ids); } if (!$this->request->filled('orderBy')) { $model = $model->orderByDesc('id'); } if (!isAdminModule()) { $model = $model->where('user_id', login_user_id()); } else { if (Menu::checkUserIsBtn(151)) { //全部数据 } elseif (Menu::checkUserIsBtn(150)) { $admin = login_admin(); $model = $model->whereHas('user', function ($q) use ($admin) { return $q->where('kefu_tag', $admin['user_tag']); }); } else { $model = $model->where('id', 0); } } return $model; } }