/** * Get the validation rules that apply to the request. * * @return array */ public function rules() { switch ($this->method) { case 'GET': break; case 'DELETE': break; case 'POST': return Contact::createRules($this); case 'PUT': break; case 'PATCH': return Contact::updateRules($this); default: break; } return []; }
/** * {@inheritdoc}. */ protected function getValidator($model) { $data = $this->getModelAsArrayForDirtyAttributes($model); $updateRules = $this->getUpdateRulesForDirtyAttributes(Contact::updateRules($model)); return Validator::make($data, $updateRules); }