mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2024-11-27 11:20:39 -06:00
95 lines
1.9 KiB
PHP
95 lines
1.9 KiB
PHP
<?php namespace FireflyIII\Models;
|
|
|
|
use Crypt;
|
|
use Illuminate\Database\Eloquent\Model;
|
|
|
|
/**
|
|
* Class Bill
|
|
*
|
|
* @package FireflyIII\Models
|
|
*/
|
|
class Bill extends Model
|
|
{
|
|
|
|
protected $fillable
|
|
= ['name', 'match', 'amount_min', 'match_encrypted', 'name_encrypted', 'user_id', 'amount_max', 'date', 'repeat_freq', 'skip', 'automatch', 'active',];
|
|
|
|
/**
|
|
* @return array
|
|
*/
|
|
public function getDates()
|
|
{
|
|
return ['created_at', 'updated_at', 'date'];
|
|
}
|
|
|
|
/**
|
|
* @param $value
|
|
*
|
|
* @return string
|
|
*/
|
|
public function getMatchAttribute($value)
|
|
{
|
|
|
|
if (intval($this->match_encrypted) == 1) {
|
|
return Crypt::decrypt($value);
|
|
}
|
|
|
|
// @codeCoverageIgnoreStart
|
|
return $value;
|
|
// @codeCoverageIgnoreEnd
|
|
}
|
|
|
|
/**
|
|
* @param $value
|
|
*
|
|
* @return string
|
|
*/
|
|
public function getNameAttribute($value)
|
|
{
|
|
|
|
if (intval($this->name_encrypted) == 1) {
|
|
return Crypt::decrypt($value);
|
|
}
|
|
|
|
// @codeCoverageIgnoreStart
|
|
return $value;
|
|
// @codeCoverageIgnoreEnd
|
|
}
|
|
|
|
/**
|
|
* @param $value
|
|
*/
|
|
public function setMatchAttribute($value)
|
|
{
|
|
$this->attributes['match'] = Crypt::encrypt($value);
|
|
$this->attributes['match_encrypted'] = true;
|
|
}
|
|
|
|
/**
|
|
* @param $value
|
|
*/
|
|
public function setNameAttribute($value)
|
|
{
|
|
$this->attributes['name'] = Crypt::encrypt($value);
|
|
$this->attributes['name_encrypted'] = true;
|
|
}
|
|
|
|
/**
|
|
* @return \Illuminate\Database\Eloquent\Relations\HasMany
|
|
*/
|
|
public function transactionjournals()
|
|
{
|
|
return $this->hasMany('FireflyIII\Models\TransactionJournal');
|
|
}
|
|
|
|
/**
|
|
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo
|
|
*/
|
|
public function user()
|
|
{
|
|
return $this->belongsTo('FireflyIII\User');
|
|
}
|
|
|
|
|
|
}
|