2015-02-27 09:48:33 -06:00
|
|
|
<?php namespace FireflyIII\Models;
|
|
|
|
|
2016-01-01 14:49:27 -06:00
|
|
|
use Carbon\Carbon;
|
|
|
|
use Illuminate\Database\Eloquent\Collection;
|
2015-02-27 09:48:33 -06:00
|
|
|
use Illuminate\Database\Eloquent\Model;
|
|
|
|
|
|
|
|
/**
|
2016-01-01 14:49:27 -06:00
|
|
|
* FireflyIII\Models\BudgetLimit
|
2015-02-27 09:48:33 -06:00
|
|
|
*
|
2016-01-01 14:49:27 -06:00
|
|
|
* @property integer $id
|
|
|
|
* @property Carbon $created_at
|
|
|
|
* @property Carbon $updated_at
|
|
|
|
* @property integer $budget_id
|
|
|
|
* @property Carbon $startdate
|
|
|
|
* @property float $amount
|
|
|
|
* @property boolean $repeats
|
|
|
|
* @property string $repeat_freq
|
|
|
|
* @property-read Budget $budget
|
|
|
|
* @property-read Collection|LimitRepetition[] $limitrepetitions
|
2015-02-27 09:48:33 -06:00
|
|
|
*/
|
|
|
|
class BudgetLimit extends Model
|
|
|
|
{
|
|
|
|
|
2015-05-23 10:11:16 -05:00
|
|
|
protected $hidden = ['amount_encrypted'];
|
|
|
|
|
2015-02-27 09:48:33 -06:00
|
|
|
/**
|
|
|
|
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo
|
|
|
|
*/
|
|
|
|
public function budget()
|
|
|
|
{
|
|
|
|
return $this->belongsTo('FireflyIII\Models\Budget');
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @return array
|
|
|
|
*/
|
|
|
|
public function getDates()
|
|
|
|
{
|
|
|
|
return ['created_at', 'updated_at', 'startdate'];
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @return \Illuminate\Database\Eloquent\Relations\HasMany
|
|
|
|
*/
|
|
|
|
public function limitrepetitions()
|
|
|
|
{
|
|
|
|
return $this->hasMany('FireflyIII\Models\LimitRepetition');
|
|
|
|
}
|
|
|
|
|
2015-05-23 01:46:46 -05:00
|
|
|
/**
|
|
|
|
* @param $value
|
|
|
|
*/
|
|
|
|
public function setAmountAttribute($value)
|
|
|
|
{
|
2015-05-24 01:00:40 -05:00
|
|
|
$this->attributes['amount'] = strval(round($value, 2));
|
2015-05-23 01:46:46 -05:00
|
|
|
}
|
|
|
|
|
2015-02-27 09:48:33 -06:00
|
|
|
}
|