request = $request; } /** * @inheritDoc */ public function apply($model, RepositoryInterface $repository) { if ($no = $this->request->get('no', false)) { $model = $model->where('no', $no); } if ($this->request->filled('status')) { $model = $model->where('status', $this->request->get('status')); } if ($this->request->filled('device_id')) { $model = $model->where('device_id', $this->request->get('device_id')); } if ($this->request->filled('shop_id')) { $model = $model->where('shop_id', $this->request->get('shop_id')); } if ($this->request->filled('mobile')) { $mobile = $this->request->get('mobile'); $model = $model->whereHas('user', function ($query) use ($mobile) { return $query->where('mobile', 'like', "%{$mobile}%"); }); } $model = $model->orderBy("id", 'desc'); //用户 if (is_user_login()) { // if ($this->request->filled('user_id')) { // $model = $model->where('user_id', $this->request->get('user_id')); // } else { $model = $model->where('user_id', login_user_id()); // } } //管理员 if (is_admin_login()) { $admin = login_admin(); switch ($admin->type) { case Role::Merchants: $model = $model->where('merchant_id', $admin->id); break; case Role::Admin: break; case Role::Agency: $model = $model->where('agency_id', $admin->id); break; case Role::Invest: $model = $model->where('invest_id', $admin->id); break; } } return parent::apply($model, $repository); } }