diff --git a/app/Person.php b/app/Person.php index 2a8e8b2..344b720 100644 --- a/app/Person.php +++ b/app/Person.php @@ -127,6 +127,22 @@ class Person extends Model return $this->hasManyThrough('\App\SubBooking', '\App\PersonTarget'); } + /* + * Return, if the person is even. + * + * @return boolean + */ + public function isEven() + { + foreach ($this->targets as $target) { + if (!$target->isPaid()) { + return false; + } + } + + return true; + } + /* * Get the full name of the person. * @@ -140,4 +156,7 @@ class Person extends Model return $this->surname . ' ' . $this->name_or_company; } } + + // Make all attributes mass assignable. + protected $guarded = []; }