Skip to content

Commit

Permalink
fix: skip resource eager loading if manually eager loaded
Browse files Browse the repository at this point in the history
  • Loading branch information
SychO9 committed Nov 23, 2024
1 parent 41e5ff2 commit 464b67f
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions framework/core/src/Api/Resource/AbstractDatabaseResource.php
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,9 @@ protected function getAttributeValue(Model $model, Field $field, Context $contex
EloquentBuffer::add($model, $relationName, $aggregate);

return function () use ($model, $relationName, $relationship, $field, $context, $aggregate) {
EloquentBuffer::load($model, $relationName, $relationship, $context, $aggregate);
if (! $model->hasAttribute($this->property($field))) {
EloquentBuffer::load($model, $relationName, $relationship, $context, $aggregate);
}

return $model->getAttribute($this->property($field));
};
Expand Down Expand Up @@ -140,7 +142,9 @@ protected function getRelationshipValue(Model $model, Relationship $field, Conte
EloquentBuffer::add($model, $method);

return function () use ($model, $method, $field, $context) {
EloquentBuffer::load($model, $method, $field, $context);
if (! $model->relationLoaded($method)) {
EloquentBuffer::load($model, $method, $field, $context);
}

$data = $model->getRelation($method);

Expand Down

0 comments on commit 464b67f

Please sign in to comment.