If you get the source account attribute before the model is saved, the cache breaks.

This commit is contained in:
James Cole 2016-01-13 14:01:09 +01:00
parent cf4d7cfeef
commit ae3258b449

View File

@ -308,16 +308,8 @@ class TransactionJournal extends Model
*/
public function getSourceAccountAttribute()
{
$cache = new CacheProperties;
$cache->addProperty($this->id);
$cache->addProperty('sourceAccount');
if ($cache->has()) {
return $cache->get(); // @codeCoverageIgnore
}
$account = $this->transactions()->where('amount', '<', 0)->first()->account;
$cache->store($account);
return $account;
}