Only validate dirty attributes

To prevent unique-checking queries on every update
This commit is contained in:
Toby Zerner 2015-06-01 12:26:44 +09:30
parent 761b76539d
commit ccf63a65e9

View File

@ -130,9 +130,11 @@ class Model extends Eloquent
*/ */
protected function makeValidator() protected function makeValidator()
{ {
$rules = $this->expandUniqueRules(static::$rules); $dirty = $this->getDirty();
return static::$validator->make($this->attributes, $rules); $rules = $this->expandUniqueRules(array_only(static::$rules, array_keys($dirty)));
return static::$validator->make($dirty, $rules);
} }
/** /**