Skip to content

Commit

Permalink
优化绑定属性到父模型时数据获取
Browse files Browse the repository at this point in the history
  • Loading branch information
qeq66 authored and liu21st committed Jun 25, 2024
1 parent 855c4b1 commit d20e4a9
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/model/concern/Conversion.php
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ public function appendRelationAttr(string $attr, array $append)
throw new Exception('bind attr has exists:' . $key);
}

$this->data[$key] = $model->$attr;
$this->data[$key] = $model->getAttr($attr);
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/model/concern/RelationShip.php
Original file line number Diff line number Diff line change
Expand Up @@ -384,7 +384,7 @@ public function bindAttr(string $relation, array $attrs = [])
throw new Exception('bind attr has exists:' . $key);
}

$this->set($key, $relation ? $relation->$attr : null);
$this->set($key, $relation ? $relation->getAttr($attr) : null);
}

return $this;
Expand Down
2 changes: 1 addition & 1 deletion src/model/relation/MorphOne.php
Original file line number Diff line number Diff line change
Expand Up @@ -365,7 +365,7 @@ protected function bindAttr(Model $result, Model $model = null): void
throw new Exception('bind attr has exists:' . $key);
}

$result->setAttr($key, $model?->$attr);
$result->setAttr($key, $model?->getAttr($attr));
}
}
}
2 changes: 1 addition & 1 deletion src/model/relation/OneToOne.php
Original file line number Diff line number Diff line change
Expand Up @@ -322,7 +322,7 @@ protected function bindAttr(Model $result, Model $model = null): void
throw new Exception('bind attr has exists:' . $key);
}

$result->setAttr($key, $model?->$attr);
$result->setAttr($key, $model?->getAttr($attr));
}
}

Expand Down

0 comments on commit d20e4a9

Please sign in to comment.