Skip to content

Commit

Permalink
改进
Browse files Browse the repository at this point in the history
  • Loading branch information
liu21st committed Dec 18, 2024
1 parent 5fc6214 commit 8d305da
Showing 1 changed file with 3 additions and 7 deletions.
10 changes: 3 additions & 7 deletions src/model/concern/Attribute.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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) {
Expand Down

0 comments on commit 8d305da

Please sign in to comment.