Commit 634079b3 authored by 梁俊杰's avatar 梁俊杰

自动生成,验证器更新规则调整操作

parent 3635d0c1
...@@ -121,7 +121,7 @@ class MakeModelCommand extends HyperfCommand ...@@ -121,7 +121,7 @@ class MakeModelCommand extends HyperfCommand
if (!Str::contains($v, "_to_") && ($this->input->getOption('model') || $this->input->getOption('all'))) { if (!Str::contains($v, "_to_") && ($this->input->getOption('model') || $this->input->getOption('all'))) {
$this->makeModel(); $this->makeModel();
} }
if (!Str::contains($v, "_to_") && $this->input->getOption('controller') || $this->input->getOption('all')) { if (!Str::contains($v, "_to_") && ($this->input->getOption('controller') || $this->input->getOption('all'))) {
$this->makeValidator(); $this->makeValidator();
$this->makeRepositoryInterface(); $this->makeRepositoryInterface();
$this->makeRepository(); $this->makeRepository();
...@@ -563,8 +563,11 @@ class MakeModelCommand extends HyperfCommand ...@@ -563,8 +563,11 @@ class MakeModelCommand extends HyperfCommand
$rules .= "\t\t\t'" . $name . "' => '" . implode("|", $rs) . "'," . ($comment ? "// " . $comment . "-" . $type : "//" . $type) . "\n"; $rules .= "\t\t\t'" . $name . "' => '" . implode("|", $rs) . "'," . ($comment ? "// " . $comment . "-" . $type : "//" . $type) . "\n";
} }
$messages = join(",\n", $messages); $messages = join(",\n", $messages);
$patterns = ["%ModelClass%", '%rules%', '%attributes%', '%messages%']; $patterns = ["%ModelClass%", '%createRules%', '%updateRules%', '%attributes%', '%messages%'];
$replacements = [$modelClass, $rules, $attributes, $messages]; $createRules = $rules;
$updateRules = str_replace("nullable", "sometimes", $rules);
$updateRules = str_replace("required", "sometimes", $updateRules);
$replacements = [$modelClass, $createRules, $updateRules, $attributes, $messages];
$content = $this->buildField($patterns, $replacements, $content); $content = $this->buildField($patterns, $replacements, $content);
$this->writeToFile($file, $content); $this->writeToFile($file, $content);
} }
......
...@@ -18,10 +18,10 @@ class %ModelClass%Validator extends HyperfValidator ...@@ -18,10 +18,10 @@ class %ModelClass%Validator extends HyperfValidator
{ {
protected $rules = [ protected $rules = [
ValidatorInterface::RULE_CREATE => [ ValidatorInterface::RULE_CREATE => [
%rules% %createRules%
], ],
ValidatorInterface::RULE_UPDATE => [ ValidatorInterface::RULE_UPDATE => [
%rules% %updateRules%
], ],
]; ];
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment