mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-10-12 15:35:15 +00:00
Cleaning up and bug fixing.
This commit is contained in:
@@ -1,7 +1,8 @@
|
||||
<?php namespace FireflyIII\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
use Illuminate\Database\Eloquent\Builder as EloquentBuilder;
|
||||
use Carbon\Carbon;
|
||||
/**
|
||||
* Class PiggyBankRepetition
|
||||
*
|
||||
@@ -26,4 +27,25 @@ class PiggyBankRepetition extends Model
|
||||
return $this->belongsTo('FireflyIII\Models\PiggyBank');
|
||||
}
|
||||
|
||||
/**
|
||||
* @param EloquentBuilder $query
|
||||
* @param Carbon $date
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function scopeRelevantOnDate(EloquentBuilder $query, Carbon $date)
|
||||
{
|
||||
return $query->where(
|
||||
function($q) use ($date) {
|
||||
$q->where('startdate', '>=', $date->format('Y-m-d 00:00:00'));
|
||||
$q->orWhereNull('startdate');
|
||||
})
|
||||
|
||||
->where(function($q) use ($date) {
|
||||
|
||||
$q->where('targetdate', '<=', $date->format('Y-m-d 00:00:00'));
|
||||
$q->orWhereNull('targetdate');
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
Reference in New Issue
Block a user