We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 02eebb6 commit 05f746aCopy full SHA for 05f746a
lib/Relationships/HasManyRelationship.php
@@ -58,10 +58,12 @@ public function query(bool $hookResults = true): ModelQuery
58
$query = $this->referenceModel::query()
59
->where("{$this->foreignKeyColumn} = ?", $pkVal);
60
61
- $query->addResultHook(function (Model $model) {
62
- $pkVal = $model->getPrimaryKeyValue();
63
- $this->loadedModels[$pkVal] = $model;
64
- });
+ if ($hookResults) {
+ $query->addResultHook(function (Model $model) {
+ $pkVal = $model->getPrimaryKeyValue();
+ $this->loadedModels[$pkVal] = $model;
65
+ });
66
+ }
67
68
return $query;
69
}
0 commit comments