From 89a86771b4d6b531f4a6c56f0c700e69d366b123 Mon Sep 17 00:00:00 2001 From: Lukas Halbritter Date: Tue, 25 Sep 2018 15:07:33 +0200 Subject: [PATCH] Made Person mass assignable. Added an isEven() function to check, if the person has any open targets. --- app/Person.php | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) 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 = []; }