mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-10-12 15:35:15 +00:00
Updated models for encryption.
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
<?php namespace FireflyIII\Models;
|
||||
|
||||
use Auth;
|
||||
use Crypt;
|
||||
use DB;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
@@ -51,4 +52,31 @@ class LimitRepetition extends Model
|
||||
return floatval($sum);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $value
|
||||
*
|
||||
* @return float|int
|
||||
*/
|
||||
public function getAmountAttribute($value)
|
||||
{
|
||||
if (is_null($this->amount_encrypted)) {
|
||||
return $value;
|
||||
}
|
||||
$value = intval(Crypt::decrypt($this->amount_encrypted));
|
||||
$value = $value / 100;
|
||||
|
||||
return $value;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $value
|
||||
*/
|
||||
public function setAmountAttribute($value)
|
||||
{
|
||||
// save in cents:
|
||||
$value = intval($value * 100);
|
||||
$this->attributes['amount_encrypted'] = Crypt::encrypt($value);
|
||||
$this->attributes['amount'] = ($value / 100);
|
||||
}
|
||||
|
||||
}
|
||||
|
Reference in New Issue
Block a user