From 23fb6e8efdcfe49c44c22c939bc66769fd8f60ae Mon Sep 17 00:00:00 2001 From: scottsteil Date: Thu, 19 Oct 2017 15:17:11 -0600 Subject: [PATCH] Update ValidatingTrait.php The attributesToArray method already returns attributes that are mutated and converts Carbon dates to strings. Plus, it adds appended accessors, and applies type casting. --- src/ValidatingTrait.php | 15 +-------------- 1 file changed, 1 insertion(+), 14 deletions(-) diff --git a/src/ValidatingTrait.php b/src/ValidatingTrait.php index 80cf642..8b0d60e 100644 --- a/src/ValidatingTrait.php +++ b/src/ValidatingTrait.php @@ -136,20 +136,7 @@ public function getModel() */ public function getModelAttributes() { - $attributes = $this->getModel()->getAttributes(); - - foreach ($attributes as $key => $value) { - // The validator doesn't handle Carbon instances, so instead of casting - // them we'll return their raw value instead. - if (in_array($key, $this->getDates()) || $this->isDateCastable($key)) { - $attributes[$key] = $value; - continue; - } - - $attributes[$key] = $this->getModel()->getAttributeValue($key); - } - - return $attributes; + return $this->getModel()->attributesToArray(); } /**