From f0e398d5917c4182243943534796a911cbcd5266 Mon Sep 17 00:00:00 2001 From: Nikolay Novikov Date: Thu, 7 Nov 2019 11:07:40 +0300 Subject: [PATCH] additional rules feature --- src/ModelTrait.php | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/ModelTrait.php b/src/ModelTrait.php index 5435093..a40e1e0 100644 --- a/src/ModelTrait.php +++ b/src/ModelTrait.php @@ -137,8 +137,14 @@ public function scopeValidate(\Illuminate\Database\Eloquent\Builder $query, $pre $validator->setAttributeNames($this->getAttributeNames()); $validator->after([$this, 'saveValidation']); - $passes = $validator->passes(); + + if ($passes && $validator->getRules()) { + $validator = \Validator::make($this->attributes, $validator->getRules()); + $validator->setAttributeNames($this->getAttributeNames()); + + $passes = $validator->passes(); + } } if (! $passes) {