diff --git a/app/PersonTarget.php b/app/PersonTarget.php index c235608..f16c984 100644 --- a/app/PersonTarget.php +++ b/app/PersonTarget.php @@ -31,6 +31,11 @@ class PersonTarget extends Model return $this->hasMany('App\SubBooking'); } + public function person() + { + return $this->belongsTo('App\Person'); + } + /************************************************************************** * INDIRECT RELATIONS * **************************************************************************/ @@ -88,6 +93,16 @@ class PersonTarget extends Model * 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. * @@ -162,6 +177,9 @@ class PersonTarget extends Model case 'paid': $having = 'target = actual'; break; + case 'open': + $having = 'target != actual'; + break; case 'underpaid': $having = '(target > 0 AND target > actual) OR ' . '(target < 0 AND target < actual)';