mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-02-25 18:45:27 -06:00
New stuff for encrypted amounts.
This commit is contained in:
@@ -150,6 +150,23 @@ class Account extends Model
|
||||
// @codeCoverageIgnoreEnd
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param $value
|
||||
*
|
||||
* @return float|int
|
||||
*/
|
||||
public function getVirtualBalanceAttribute($value)
|
||||
{
|
||||
if (is_null($this->virtual_balance_encrypted)) {
|
||||
return $value;
|
||||
}
|
||||
$value = intval(Crypt::decrypt($this->virtual_balance_encrypted));
|
||||
$value = $value / 100;
|
||||
|
||||
return $value;
|
||||
}
|
||||
|
||||
/**
|
||||
* @codeCoverageIgnore
|
||||
* @return \Illuminate\Database\Eloquent\Relations\HasMany
|
||||
@@ -203,6 +220,17 @@ class Account extends Model
|
||||
$this->attributes['encrypted'] = true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $value
|
||||
*/
|
||||
public function setVirtualBalanceAttribute($value)
|
||||
{
|
||||
// save in cents:
|
||||
$value = intval($value * 100);
|
||||
$this->attributes['virtual_balance_encrypted'] = Crypt::encrypt($value);
|
||||
$this->attributes['virtual_balance'] = 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* @codeCoverageIgnore
|
||||
* @return \Illuminate\Database\Eloquent\Relations\HasMany
|
||||
|
||||
Reference in New Issue
Block a user