Files
firefly-iii/app/Models/AccountMeta.php

60 lines
1.1 KiB
PHP
Raw Normal View History

2016-05-20 08:57:45 +02: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 08:57:45 +02:00
declare(strict_types = 1);
namespace FireflyIII\Models;
2015-02-06 04:52:16 +01:00
use Illuminate\Database\Eloquent\Model;
2016-04-06 09:27:45 +02:00
use Illuminate\Database\Eloquent\Relations\BelongsTo;
2015-02-06 04:52:16 +01:00
2016-11-18 20:06:08 +01:00
/**
* Class AccountMeta
*
* @package FireflyIII\Models
*/
2015-02-06 05:04:06 +01:00
class AccountMeta extends Model
{
2015-02-06 04:52:16 +01:00
2016-01-15 23:12:52 +01:00
protected $dates = ['created_at', 'updated_at'];
2015-02-23 21:19:16 +01:00
protected $fillable = ['account_id', 'name', 'data'];
2015-06-06 23:09:12 +02:00
protected $table = 'account_meta';
2015-02-11 07:35:10 +01:00
/**
*
2016-04-06 09:27:45 +02:00
* @return BelongsTo
2015-02-11 07:35:10 +01:00
*/
2016-04-06 09:27:45 +02:00
public function account(): BelongsTo
2015-02-06 05:04:06 +01:00
{
2015-02-06 05:35:00 +01:00
return $this->belongsTo('FireflyIII\Models\Account');
2015-02-06 05:04:06 +01:00
}
2015-02-11 07:35:10 +01:00
/**
* @param $value
*
* @return mixed
*/
2015-02-06 05:04:06 +01:00
public function getDataAttribute($value)
{
return json_decode($value);
}
2015-02-11 07:35:10 +01:00
/**
* @param $value
*/
2015-02-07 13:15:40 +01:00
public function setDataAttribute($value)
{
$this->attributes['data'] = json_encode($value);
}
2015-02-06 04:52:16 +01:00
}