From edfec8407465d67df21af95360740c12711bda81 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Benjamin=20Beganovi=C4=87?= Date: Fri, 14 Aug 2020 14:53:36 +0200 Subject: [PATCH] Add new properties to models for easier fetching: Invoice: - balance_due is now alias to balance - total is now alias to calc()->getTotal() Quote: - valid_until is now alias to due_date - balance_due is now alias to balance --- app/Models/Invoice.php | 10 ++++++++++ app/Models/Quote.php | 15 +++++++++++++++ 2 files changed, 25 insertions(+) diff --git a/app/Models/Invoice.php b/app/Models/Invoice.php index 590bd9fcff92..e1a9c2153a12 100644 --- a/app/Models/Invoice.php +++ b/app/Models/Invoice.php @@ -496,4 +496,14 @@ class Invoice extends BaseModel // } // } // } + + public function getBalanceDueAttribute() + { + return $this->balance; + } + + public function getTotalAttribute() + { + return $this->calc()->getTotal(); + } } diff --git a/app/Models/Quote.php b/app/Models/Quote.php index df0035c1bae5..b8c06d4cf7c0 100644 --- a/app/Models/Quote.php +++ b/app/Models/Quote.php @@ -250,4 +250,19 @@ class Quote extends BaseModel return false; } + + public function getValidUntilAttribute() + { + return $this->due_date; + } + + public function getBalanceDueAttribute() + { + return $this->balance; + } + + public function getTotalAttribute() + { + return $this->calc()->getTotal(); + } }