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