Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/Model.php
Original file line number Diff line number Diff line change
Expand Up @@ -452,7 +452,7 @@ protected function validateAndFilterData(bool $isUpdate): array
} elseif ($isUpdate && !$this->isForce() && $this->isNotRequireUpdate($name, $val, $origin)) {
unset($data[$name]);
} else {
$val = $this->setWithAttr($name, $val);
$val = $this->setAttrOfWith($name, $val);
}
}

Expand Down Expand Up @@ -788,7 +788,7 @@ public function __get(string $name)
*/
public function __set(string $name, $value): void
{
if ($value instanceof Modelable && $bind = $this->getBindAttr($this->getOption('bindAttr'), $name)) {
if ($value instanceof Modelable && $bind = $this->getAttrOfBind($this->getOption('bindAttr'), $name)) {
// 关联属性绑定
$this->bindRelationAttr($value, $bind);
} else {
Expand Down
4 changes: 2 additions & 2 deletions src/model/View.php
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ protected function initData(bool $with = false)
$this->$field = $this->fetchViewAttr($field, $data, $with);
} elseif (strpos($field, '->')) {
// 关联属性或JSON字段映射
$this->$key = $this->getRelationMapAttr($field, $data);
$this->$key = $this->getAttrOfRelationMap($field, $data);
} else {
// 主模型属性映射
$this->$key = $this->fetchViewAttr($field, $data, $with);
Expand All @@ -80,7 +80,7 @@ protected function initData(bool $with = false)
*
* @return mixed
*/
private function getRelationMapAttr(string $field, array $data)
private function getAttrOfRelationMap(string $field, array $data)
{
$items = explode('->', $field);
$relation = array_shift($items);
Expand Down
6 changes: 3 additions & 3 deletions src/model/concern/Attribute.php
Original file line number Diff line number Diff line change
Expand Up @@ -516,7 +516,7 @@ protected function hasGetAttr(string $name): bool
*
* @return mixed
*/
private function setWithAttr(string $name, $value)
private function setAttrOfWith(string $name, $value)
{
$attr = Str::studly($name);
$method = 'set' . $attr . 'Attr';
Expand Down Expand Up @@ -572,7 +572,7 @@ public function get(string $name, bool $attr = true)

if ($attr) {
// 通过获取器输出
$value = $this->getWithAttr($name, $value, $this->getData());
$value = $this->getAttrOfWith($name, $value, $this->getData());
$this->setWeakData('get', $name, $value);
}

Expand Down Expand Up @@ -601,7 +601,7 @@ protected function getMappingName(string $name): string
*
* @return mixed
*/
private function getWithAttr(string $name, $value, array $data = [])
private function getAttrOfWith(string $name, $value, array $data = [])
{
$attr = Str::studly($name);
$method = 'get' . $attr . 'Attr';
Expand Down
2 changes: 1 addition & 1 deletion src/model/concern/AutoWriteData.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ protected function autoWriteData(array &$data, bool $update, array $allow = [])
if ($val instanceof Closure) {
$value = $val($this);
} else {
$value = is_string($name) ? $val : $this->setWithAttr($field, null, $data);
$value = is_string($name) ? $val : $this->setAttrOfWith($field, null);
}
$data[$field] = $value;
$this->setData($field, $value);
Expand Down
2 changes: 1 addition & 1 deletion src/model/concern/Conversion.php
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ public function toArray(): array
$item[$name] = $val->toArray();
} elseif (empty($allow) || in_array($name, $allow)) {
// 通过获取器输出
$item[$name] = $this->getWithAttr($name, $val, $data);
$item[$name] = $this->getAttrOfWith($name, $val, $data);
}

if (array_key_exists($name, $item) && isset($mapping[$name])) {
Expand Down
4 changes: 2 additions & 2 deletions src/model/concern/RelationShip.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ private function parseRelationData(array $relations)
foreach ($relations as $relation => $val) {
$relation = $this->getRealFieldName($relation);
$type = $this->getFields($relation);
$bind = $this->getBindAttr($this->getOption('bindAttr'), $relation);
$bind = $this->getAttrOfBind($this->getOption('bindAttr'), $relation);
if (!empty($bind)) {
// 绑定关联属性
$this->bindRelationAttr($val, $bind, $relation);
Expand Down Expand Up @@ -216,7 +216,7 @@ public function hasRelation(string $name)
return false;
}

protected function getBindAttr($bind, $name)
protected function getAttrOfBind($bind, $name)
{
return $bind[$name] ?? [];
}
Expand Down