firefly-iii/app/models/AccountMeta.php

65 lines
1.7 KiB
PHP
Raw Normal View History

2014-11-10 11:38:58 -06:00
<?php
use LaravelBook\Ardent\Ardent as Ardent;
2014-11-17 00:33:18 -06:00
2014-11-10 11:38:58 -06:00
/**
* AccountMeta
*
* @property-read \Account $account
2014-12-05 15:50:26 -06:00
* @property integer $id
* @property \Carbon\Carbon $created_at
* @property \Carbon\Carbon $updated_at
* @property integer $account_id
* @property string $name
* @property string $data
* @method static \Illuminate\Database\Query\Builder|\AccountMeta whereId($value)
* @method static \Illuminate\Database\Query\Builder|\AccountMeta whereCreatedAt($value)
* @method static \Illuminate\Database\Query\Builder|\AccountMeta whereUpdatedAt($value)
* @method static \Illuminate\Database\Query\Builder|\AccountMeta whereAccountId($value)
* @method static \Illuminate\Database\Query\Builder|\AccountMeta whereName($value)
* @method static \Illuminate\Database\Query\Builder|\AccountMeta whereData($value)
2014-11-10 11:38:58 -06:00
*/
class AccountMeta extends Ardent
{
/**
* @var array
*/
public static $rules
2014-11-17 13:45:55 -06:00
= [
'account_id' => 'numeric|required|exists:accounts,id',
'name' => 'required|between:1,250',
2014-12-05 14:39:34 -06:00
'data' => 'required'
];
2014-11-10 11:38:58 -06:00
/**
* @var array
*/
protected $fillable = ['account_id', 'name', 'date'];
2014-12-05 14:39:34 -06:00
protected $table = 'account_meta';
2014-11-10 11:38:58 -06:00
/**
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo
*/
public function account()
{
return $this->belongsTo('Account');
}
2014-12-05 14:39:34 -06:00
/**
* @param $value
*
* @return mixed
*/
public function getDataAttribute($value)
{
return json_decode($value);
}
/**
* @param $value
*/
public function setDataAttribute($value)
{
$this->attributes['data'] = json_encode($value);
}
2014-11-10 11:38:58 -06:00
}