From 1e9e90ec17a7956a7eddbc768ea58f85fad54cc0 Mon Sep 17 00:00:00 2001 From: Lukas Halbritter Date: Thu, 4 Oct 2018 20:34:26 +0200 Subject: [PATCH] The fullName() method is now able to return the name, but in the form 'LAST NAME, FIRST NAME'. --- app/Person.php | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/app/Person.php b/app/Person.php index 8b6dfcf..338d200 100644 --- a/app/Person.php +++ b/app/Person.php @@ -70,14 +70,21 @@ class Person extends Model /** * Get the full name of the person. + * If $reverse is true, return a comma-spearated string of the name with the + * last name first. * + * @param boolean $reverse * @return string */ - public function fullName() + public function fullName($reverse = false) { if ($this->title == 'Firma') { return $this->name_or_company; } else { + if ($reverse) { + return $this->name_or_company . ', ' . $this->surname; + } + return $this->surname . ' ' . $this->name_or_company; } }