diff --git a/app/Models/Client.php b/app/Models/Client.php index 6d6dd0b4bc340..0949d4948f11d 100644 --- a/app/Models/Client.php +++ b/app/Models/Client.php @@ -49,6 +49,13 @@ class Client extends EntityModel 'website', ]; + /** + * @var array + */ + protected $appends = [ + 'display_name', + ]; + /** * @var string */ @@ -331,6 +338,17 @@ class Client extends EntityModel return $contact->getDisplayName(); } + /** + * Making the virtual property display_name accessible + * via an accessor + * + * @return mixed|string + */ + public function getDisplayNameAttribute() + { + return $this->getDisplayName(); + } + /** * @return string */ diff --git a/app/Models/Invoice.php b/app/Models/Invoice.php index 432e811bff6a9..95a0cfaa5674a 100644 --- a/app/Models/Invoice.php +++ b/app/Models/Invoice.php @@ -140,7 +140,9 @@ class Invoice extends EntityModel implements BalanceAffecting */ public function getDisplayName() { - return $this->is_recurring ? trans('texts.recurring') : $this->invoice_number; + return $this->is_recurring + ? trans('texts.recurring') + : $this->invoice_number.' ('.$this->client->display_name.')'; } /**