Cleaning up and bug fixing.

This commit is contained in:
James Cole
2015-03-02 20:05:28 +01:00
parent ad2aebb54d
commit b1af6bab28
20 changed files with 363 additions and 143 deletions

View File

@@ -10,6 +10,8 @@ use Illuminate\Database\Eloquent\Model;
class PiggyBankEvent extends Model
{
protected $fillable = ['piggy_bank_id', 'transaction_journal_id', 'date', 'amount'];
/**
* @return array
*/

View File

@@ -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');
});
}
}