From cd3e3cda0e4993f7825379a5c5b3a3cdc5fd6a29 Mon Sep 17 00:00:00 2001 From: Mohamed Said Date: Wed, 12 Oct 2016 22:14:12 +0300 Subject: [PATCH] [5.3] return null if an empty key was passed to getAttribute (#15874) * return null if an empty key was passed to getAttribute * fix code style --- src/Illuminate/Database/Eloquent/Model.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/Illuminate/Database/Eloquent/Model.php b/src/Illuminate/Database/Eloquent/Model.php index 3c1bf9a81d78..5fe4bb82da82 100644 --- a/src/Illuminate/Database/Eloquent/Model.php +++ b/src/Illuminate/Database/Eloquent/Model.php @@ -2596,6 +2596,10 @@ protected function getArrayableItems(array $values) */ public function getAttribute($key) { + if (! $key) { + return; + } + if (array_key_exists($key, $this->attributes) || $this->hasGetMutator($key)) { return $this->getAttributeValue($key); }