diff --git a/src/model/concern/Attribute.php b/src/model/concern/Attribute.php index a70f56f5..0f2a1f1b 100644 --- a/src/model/concern/Attribute.php +++ b/src/model/concern/Attribute.php @@ -430,10 +430,7 @@ public function setAttrs(array $data): void public function setAttr(string $name, $value, array $data = []): void { if ($this->mapping) { - $key = array_search($name, $this->mapping); - if (is_string($key)) { - $name = $key; - } + $name = array_search($name, $this->mapping) ?: $name; } $name = $this->getRealFieldName($name); @@ -534,9 +531,8 @@ public function getAttr(string $name) { try { $relation = false; - $key = array_search($name, $this->mapping); - if (is_string($key)) { - $name = $key; + if ($this->mapping) { + $name = array_search($name, $this->mapping) ?: $name; } $value = $this->getData($name); } catch (InvalidArgumentException $e) {