Match methods

This commit is contained in:
James Cole 2014-08-19 15:30:19 +02:00
parent f00dfd2859
commit eacad20f51

View File

@ -242,6 +242,9 @@ class Piggybank extends Ardent
{
$query = $this->piggybankrepetitions()
->where(
function ($q) use ($date) {
$q->where(
function ($q) use ($date) {
$q->whereNull('startdate');
$q->orWhere('startdate', '<=', $date->format('Y-m-d'));
@ -253,6 +256,13 @@ class Piggybank extends Ardent
$q->orWhere('targetdate', '>=', $date->format('Y-m-d'));
}
);
}
)->orWhere(
function ($q) use ($date) {
$q->where('startdate', '>=', $date->format('Y-m-d'));
$q->where('targetdate', '>=', $date->format('Y-m-d'));
}
)->orderBy('startdate', 'ASC');
$result = $query->first();
return $result;