2016-05-20 08:57:45 +02:00
|
|
|
<?php
|
2016-05-20 12:41:23 +02:00
|
|
|
/**
|
|
|
|
* AccountMeta.php
|
|
|
|
* Copyright (C) 2016 thegrumpydictator@gmail.com
|
|
|
|
*
|
2016-10-05 06:52:15 +02:00
|
|
|
* 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 12:41:23 +02:00
|
|
|
*/
|
|
|
|
|
2017-04-09 07:44:22 +02:00
|
|
|
declare(strict_types=1);
|
2016-05-20 08:57:45 +02:00
|
|
|
|
|
|
|
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-12-24 17:36:51 +01: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 13:47:23 +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-14 14:25:29 +01:00
|
|
|
|
2015-02-11 07:35:10 +01:00
|
|
|
/**
|
2015-05-10 13:22:00 +02: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
|
|
|
}
|