Added methods to get the person that belongs to a target and a method to get all

targets which are nichot paid.
This commit is contained in:
Lukas Halbritter
2018-10-04 20:35:39 +02:00
parent 1e9e90ec17
commit 0907b18671
+18
View File
@@ -31,6 +31,11 @@ class PersonTarget extends Model
return $this->hasMany('App\SubBooking'); return $this->hasMany('App\SubBooking');
} }
public function person()
{
return $this->belongsTo('App\Person');
}
/************************************************************************** /**************************************************************************
* INDIRECT RELATIONS * * INDIRECT RELATIONS *
**************************************************************************/ **************************************************************************/
@@ -88,6 +93,16 @@ class PersonTarget extends Model
* COLLECTIONS FILTERED BY PAYMENT STATES * * COLLECTIONS FILTERED BY PAYMENT STATES *
**************************************************************************/ **************************************************************************/
/*
* Get all targets which are paid off.
*
* @return Illuminate\Database\Eloquent\Collection
*/
public static function open()
{
return PersonTarget::queryWhere('open');
}
/* /*
* Get all targets which are paid off. * Get all targets which are paid off.
* *
@@ -162,6 +177,9 @@ class PersonTarget extends Model
case 'paid': case 'paid':
$having = 'target = actual'; $having = 'target = actual';
break; break;
case 'open':
$having = 'target != actual';
break;
case 'underpaid': case 'underpaid':
$having = '(target > 0 AND target > actual) OR ' . $having = '(target > 0 AND target > actual) OR ' .
'(target < 0 AND target < actual)'; '(target < 0 AND target < actual)';