Skip to content

Commit

Permalink
Merge pull request #36 from kchung/fix-refresh
Browse files Browse the repository at this point in the history
Clear `mutateCache` on refresh
  • Loading branch information
kchung authored Sep 23, 2024
2 parents 7d53268 + 8533f39 commit 7ceb9b6
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/Database/Model.php
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,16 @@ public function belongsToMany($related, $table = null, $foreignPivotKey = null,
);
}

/**
* {@inheritdoc}
*/
public function refresh()
{
$this->clearMutatorCache();

return parent::refresh();
}

/**
* {@inheritdoc}
*/
Expand Down
8 changes: 8 additions & 0 deletions src/Database/Traits/HasMutators.php
Original file line number Diff line number Diff line change
Expand Up @@ -91,4 +91,12 @@ public function hasMutator($attribute)
{
return array_key_exists($attribute, $this->mutate);
}

/**
* @return void
*/
protected function clearMutatorCache()
{
$this->mutatedCache = [];
}
}

0 comments on commit 7ceb9b6

Please sign in to comment.