2014-11-10 11:38:58 -06:00
|
|
|
<?php
|
2014-12-06 05:12:55 -06:00
|
|
|
use Watson\Validating\ValidatingTrait;
|
2014-12-20 08:00:53 -06:00
|
|
|
use \Illuminate\Database\Eloquent\Model as Eloquent;
|
2014-12-13 14:59:02 -06:00
|
|
|
/**
|
|
|
|
* Class AccountMeta
|
|
|
|
*/
|
2014-12-06 05:12:55 -06:00
|
|
|
class AccountMeta extends Eloquent
|
2014-11-10 11:38:58 -06:00
|
|
|
{
|
2014-12-06 05:12:55 -06:00
|
|
|
use ValidatingTrait;
|
2014-11-10 11:38:58 -06:00
|
|
|
/**
|
|
|
|
* @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
|
|
|
}
|