eee
This commit is contained in:
+3
-3
@@ -476,7 +476,7 @@ abstract class Model extends Component implements ModelInterface, ArrayAccess, \
|
|||||||
*/
|
*/
|
||||||
public function save(): static|bool
|
public function save(): static|bool
|
||||||
{
|
{
|
||||||
if (!$this->validator($this->rules()) || !$this->beforeSave($this)) {
|
if (!$this->validator($this->rules(), $this->_attributes) || !$this->beforeSave($this)) {
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
if (!$this->isNewExample) {
|
if (!$this->isNewExample) {
|
||||||
@@ -537,13 +537,13 @@ abstract class Model extends Component implements ModelInterface, ArrayAccess, \
|
|||||||
* @return bool
|
* @return bool
|
||||||
* @throws
|
* @throws
|
||||||
*/
|
*/
|
||||||
public function validator(array $rule): bool
|
public function validator(array $rule, array $params): bool
|
||||||
{
|
{
|
||||||
if (count($rule) < 1 || $this->skipValidate) {
|
if (count($rule) < 1 || $this->skipValidate) {
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
$validate = $this->resolve($rule);
|
$validate = $this->resolve($rule);
|
||||||
if (!$validate->validation($this)) {
|
if (!$validate->validation($params)) {
|
||||||
return \Kiri::getLogger()->failure($validate->getError() . PHP_EOL, 'mysql');
|
return \Kiri::getLogger()->failure($validate->getError() . PHP_EOL, 'mysql');
|
||||||
} else {
|
} else {
|
||||||
return TRUE;
|
return TRUE;
|
||||||
|
|||||||
@@ -191,7 +191,7 @@ class Model extends Base\Model
|
|||||||
*/
|
*/
|
||||||
public function update(array $params): static|bool
|
public function update(array $params): static|bool
|
||||||
{
|
{
|
||||||
if (!$this->validator($this->rules()) || !$this->beforeSave($this)) {
|
if (!$this->validator($this->rules(), $params) || !$this->beforeSave($this)) {
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
return $this->updateInternal(...$this->arrayIntersect($params));
|
return $this->updateInternal(...$this->arrayIntersect($params));
|
||||||
|
|||||||
Reference in New Issue
Block a user