firefly-iii/app/Models/AccountMeta.php

71 lines
1.4 KiB
PHP
Raw Normal View History

2016-05-20 01:57:45 -05:00
<?php
/**
* AccountMeta.php
* Copyright (C) 2016 thegrumpydictator@gmail.com
*
* This software may be modified and distributed under the terms of the
* Creative Commons Attribution-ShareAlike 4.0 International License.
*
* See the LICENSE file for details.
*/
2016-05-20 01:57:45 -05:00
declare(strict_types = 1);
namespace FireflyIII\Models;
2015-02-05 21:52:16 -06:00
use Illuminate\Database\Eloquent\Model;
2016-04-06 02:27:45 -05:00
use Illuminate\Database\Eloquent\Relations\BelongsTo;
2015-02-05 21:52:16 -06:00
2016-11-18 13:06:08 -06:00
/**
* Class AccountMeta
*
* @package FireflyIII\Models
*/
2015-02-05 22:04:06 -06:00
class AccountMeta extends Model
{
2015-02-05 21:52:16 -06:00
2016-12-24 10:36:51 -06:00
/**
* The attributes that should be casted to native types.
*
* @var array
*/
protected $casts
= [
'created_at' => 'date',
'updated_at' => 'date',
];
/** @var array */
2016-12-30 06:47:23 -06:00
protected $dates = ['created_at', 'updated_at'];
2015-02-23 14:19:16 -06:00
protected $fillable = ['account_id', 'name', 'data'];
2015-06-06 16:09:12 -05:00
protected $table = 'account_meta';
2015-02-11 00:35:10 -06:00
/**
*
2016-04-06 02:27:45 -05:00
* @return BelongsTo
2015-02-11 00:35:10 -06:00
*/
2016-04-06 02:27:45 -05:00
public function account(): BelongsTo
2015-02-05 22:04:06 -06:00
{
2015-02-05 22:35:00 -06:00
return $this->belongsTo('FireflyIII\Models\Account');
2015-02-05 22:04:06 -06:00
}
2015-02-11 00:35:10 -06:00
/**
* @param $value
*
* @return mixed
*/
2015-02-05 22:04:06 -06:00
public function getDataAttribute($value)
{
return json_decode($value);
}
2015-02-11 00:35:10 -06:00
/**
* @param $value
*/
2015-02-07 06:15:40 -06:00
public function setDataAttribute($value)
{
$this->attributes['data'] = json_encode($value);
}
2015-02-05 21:52:16 -06:00
}