validate(); } /** * 初始化验证 * * @time 2019年11月27日 * @throws \Exception * @return mixed */ protected function validate() { if (method_exists($this, 'rules')) { try { $validate = app('validate'); // 批量验证 if ($this->batch) { $validate->batch($this->batch); } // 验证 if (!$validate->message($this->message())->check(request()->param(), $this->rules())) { throw new FailedException($validate->getError()); } } catch (\Exception $e) { throw new ValidateFailedException($e->getMessage()); } } // 设置默认参数 if ($this->needCreatorId) { $this->param['creator_id'] = $this->user()->id; $this->post['creator_id'] = $this->user()->id; } return true; } }