From ccf63a65e9f354505586d6c827b30eb93a4ea9c0 Mon Sep 17 00:00:00 2001 From: Toby Zerner Date: Mon, 1 Jun 2015 12:26:44 +0930 Subject: [PATCH] Only validate dirty attributes To prevent unique-checking queries on every update --- framework/core/src/Core/Models/Model.php | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/framework/core/src/Core/Models/Model.php b/framework/core/src/Core/Models/Model.php index 18580ba69..b5f20452b 100755 --- a/framework/core/src/Core/Models/Model.php +++ b/framework/core/src/Core/Models/Model.php @@ -130,9 +130,11 @@ class Model extends Eloquent */ 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); } /**