mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-11-21 09:00:07 +00:00
Cleaned up some icons, improved routine for repeated expenses.
This commit is contained in:
@@ -14,7 +14,9 @@ class PiggyBank extends Model
|
||||
{
|
||||
use SoftDeletes;
|
||||
|
||||
protected $fillable = ['repeats', 'name', 'account_id','rep_every', 'rep_times', 'reminder_skip', 'targetamount', 'startdate', 'targetdate', 'reminder','remind_me'];
|
||||
protected $fillable
|
||||
= ['repeats', 'name', 'account_id', 'rep_every', 'rep_times', 'reminder_skip', 'targetamount', 'startdate', 'targetdate', 'reminder', 'remind_me',
|
||||
'rep_length'];
|
||||
|
||||
/**
|
||||
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo
|
||||
@@ -24,15 +26,6 @@ class PiggyBank extends Model
|
||||
return $this->belongsTo('FireflyIII\Models\Account');
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $value
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getRemindMeAttribute($value) {
|
||||
return intval($value) == 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Grabs the PiggyBankRepetition that's currently relevant / active
|
||||
*
|
||||
@@ -40,10 +33,10 @@ class PiggyBank extends Model
|
||||
*/
|
||||
public function currentRelevantRep()
|
||||
{
|
||||
if ($this->currentRep) {
|
||||
if (!is_null($this->currentRep)) {
|
||||
return $this->currentRep;
|
||||
}
|
||||
if ($this->repeats == 0) {
|
||||
if (intval($this->repeats) === 0) {
|
||||
$rep = $this->piggyBankRepetitions()->first(['piggy_bank_repetitions.*']);
|
||||
$this->currentRep = $rep;
|
||||
|
||||
@@ -104,6 +97,16 @@ class PiggyBank extends Model
|
||||
return ['created_at', 'updated_at', 'deleted_at', 'startdate', 'targetdate'];
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $value
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getRemindMeAttribute($value)
|
||||
{
|
||||
return intval($value) == 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \Illuminate\Database\Eloquent\Relations\HasMany
|
||||
*/
|
||||
|
||||
@@ -48,4 +48,16 @@ class PiggyBankRepetition extends Model
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* @param EloquentBuilder $query
|
||||
* @param Carbon $start
|
||||
* @param Carbon $target
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function scopeOnDates(EloquentBuilder $query, Carbon $start, Carbon $target)
|
||||
{
|
||||
return $query->where('startdate',$start->format('Y-m-d'))->where('targetdate',$target->format('Y-m-d'));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user