Skip to content

Commit

Permalink
Fix fresh and refresh on pivots and morph pivots (#34836)
Browse files Browse the repository at this point in the history
  • Loading branch information
axlon committed Oct 14, 2020
1 parent ece8810 commit 9510cca
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions src/Illuminate/Database/Eloquent/Model.php
Expand Up @@ -1206,9 +1206,8 @@ public function fresh($with = [])
return;
}

return static::newQueryWithoutScopes()
return $this->setKeysForSaveQuery(static::newQueryWithoutScopes())
->with(is_string($with) ? func_get_args() : $with)
->where($this->getKeyName(), $this->getKey())
->first();
}

Expand All @@ -1224,7 +1223,7 @@ public function refresh()
}

$this->setRawAttributes(
static::newQueryWithoutScopes()->findOrFail($this->getKey())->attributes
$this->setKeysForSaveQuery(static::newQueryWithoutScopes())->firstOrFail()->attributes
);

$this->load(collect($this->relations)->reject(function ($relation) {
Expand Down

0 comments on commit 9510cca

Please sign in to comment.