From 0907b18671d736eb006c3cb80ecf8684463fb3f6 Mon Sep 17 00:00:00 2001 From: Lukas Halbritter Date: Thu, 4 Oct 2018 20:35:39 +0200 Subject: [PATCH] Added methods to get the person that belongs to a target and a method to get all targets which are nichot paid. --- app/PersonTarget.php | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) 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)';