Skip to content

Commit

Permalink
改进关联模型输出
Browse files Browse the repository at this point in the history
  • Loading branch information
liu21st authored Aug 20, 2023
1 parent c5fcb81 commit b723ee2
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions src/model/concern/RelationShip.php
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,10 @@ public function setRelation(string $name, $value, array $data = [])
$value = $this->$method($value, array_merge($this->data, $data));
}

$this->relation[$this->getRealFieldName($name)] = $value;
$name = $this->getRealFieldName($name);

$this->relation[$name] = $value;
$this->with[$name] = true;

return $this;
}
Expand Down Expand Up @@ -306,8 +309,6 @@ public function eagerlyResultSet(array &$resultSet, array $relations, array $wit
}

$relationResult->eagerlyResultSet($resultSet, $relationName, $subRelation, $closure, $relationCache, $join);

$this->with[$relationName] = true;
}
}

Expand Down Expand Up @@ -356,8 +357,6 @@ public function eagerlyResult(array $relations, array $withRelationAttr = [], bo
}

$relationResult->eagerlyResult($this, $relationName, $subRelation, $closure, $relationCache, $join);

$this->with[$relationName] = true;
}
}

Expand Down

0 comments on commit b723ee2

Please sign in to comment.