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:
@@ -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)';
|
||||
|
||||
Reference in New Issue
Block a user