Skip to content

Commit 7ceb9b6

Browse files
authored
Merge pull request #36 from kchung/fix-refresh
Clear `mutateCache` on refresh
2 parents 7d53268 + 8533f39 commit 7ceb9b6

File tree

2 files changed

+18
-0
lines changed

2 files changed

+18
-0
lines changed

src/Database/Model.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,16 @@ public function belongsToMany($related, $table = null, $foreignPivotKey = null,
9999
);
100100
}
101101

102+
/**
103+
* {@inheritdoc}
104+
*/
105+
public function refresh()
106+
{
107+
$this->clearMutatorCache();
108+
109+
return parent::refresh();
110+
}
111+
102112
/**
103113
* {@inheritdoc}
104114
*/

src/Database/Traits/HasMutators.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,4 +91,12 @@ public function hasMutator($attribute)
9191
{
9292
return array_key_exists($attribute, $this->mutate);
9393
}
94+
95+
/**
96+
* @return void
97+
*/
98+
protected function clearMutatorCache()
99+
{
100+
$this->mutatedCache = [];
101+
}
94102
}

0 commit comments

Comments
 (0)