request = $request; } /** * @inheritDoc */ public function apply($model, RepositoryInterface $repository) { if ($this->request->filled('no')) { $model = $model->where('no', $this->request->get('no')); } if ($this->request->filled('id')) { $model = $model->where('id', $this->request->get('id')); } if ($this->request->filled('shop_id')) { $model = $model->where('shop_id', $this->request->get('shop_id')); } //管理员 if (is_admin_login()) { $admin = login_admin(); switch ($admin->type) { case Role::Merchants: $model = $model->where('merchant_id', $admin->id); break; case Role::Invest: case Role::Agency: $model = $model->where(function ($query) use ($admin) { return $query->where('merchant_id', $admin->id)->orWhere('agency_id', $admin->id)->orWhere('invest_id', $admin->id); }); break; } } return parent::apply($model, $repository); } }