Skip to content

Commit 7a2d027

Browse files
committed
Mantain parent logic on attribute read for non dot keys
1 parent 3868446 commit 7a2d027

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

src/Jenssegers/Mongodb/Eloquent/Model.php

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -237,7 +237,12 @@ public function getAttribute($key)
237237
*/
238238
protected function getAttributeFromArray($key)
239239
{
240-
return array_get($this->attributes, $key);
240+
// Support keys in dot notation.
241+
if (str_contains($key, '.')) {
242+
return array_get($this->attributes, $key);
243+
}
244+
245+
return parent::getAttributeFromArray($key);
241246
}
242247

243248
/**
@@ -253,9 +258,7 @@ public function setAttribute($key, $value)
253258
$builder = $this->newBaseQueryBuilder();
254259

255260
$value = $builder->convertKey($value);
256-
}
257-
258-
// Support keys in dot notation.
261+
} // Support keys in dot notation.
259262
elseif (str_contains($key, '.')) {
260263
if (in_array($key, $this->getDates()) && $value) {
261264
$value = $this->fromDateTime($value);

0 commit comments

Comments
 (0)