From 9032793597a40de70a3f42ef2e1cbe4c67f7d1fe Mon Sep 17 00:00:00 2001 From: Lukas Halbritter Date: Thu, 4 Oct 2018 19:56:31 +0200 Subject: [PATCH] Added method to get the PersonTarget of a Booking. --- app/Booking.php | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/app/Booking.php b/app/Booking.php index 8865128..b1fb3b9 100644 --- a/app/Booking.php +++ b/app/Booking.php @@ -54,6 +54,21 @@ class Booking extends Model return null; } + /** + * Get the person target of the booking. If the booking consists of more than + * one sub-booking, null is returned. + * + * @return App\AccountType + */ + public function personTarget() + { + if ($this->isSimple()) { + return $this->subBookings->first()->personTarget; + } + + return null; + } + /************************************************************************** * INDIRECT PROPERTIES * **************************************************************************/