mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2024-12-31 19:27:51 -06:00
a950e02e9b
This reverts commit 5662a02a36
.
52 lines
1.0 KiB
PHP
52 lines
1.0 KiB
PHP
<?php
|
|
use Watson\Validating\ValidatingTrait;
|
|
use \Illuminate\Database\Eloquent\Model as Eloquent;
|
|
/**
|
|
* Class AccountMeta
|
|
*/
|
|
class AccountMeta extends Eloquent
|
|
{
|
|
use ValidatingTrait;
|
|
/**
|
|
* @var array
|
|
*/
|
|
public static $rules
|
|
= [
|
|
'account_id' => 'numeric|required|exists:accounts,id',
|
|
'name' => 'required|between:1,250',
|
|
'data' => 'required'
|
|
];
|
|
/**
|
|
* @var array
|
|
*/
|
|
protected $fillable = ['account_id', 'name', 'date'];
|
|
protected $table = 'account_meta';
|
|
|
|
/**
|
|
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo
|
|
*/
|
|
public function account()
|
|
{
|
|
return $this->belongsTo('Account');
|
|
}
|
|
|
|
/**
|
|
* @param $value
|
|
*
|
|
* @return mixed
|
|
*/
|
|
public function getDataAttribute($value)
|
|
{
|
|
return json_decode($value);
|
|
}
|
|
|
|
/**
|
|
* @param $value
|
|
*/
|
|
public function setDataAttribute($value)
|
|
{
|
|
$this->attributes['data'] = json_encode($value);
|
|
}
|
|
|
|
}
|