From 81f34b8912e6e9d33ba038f46951bc9fc172f2b3 Mon Sep 17 00:00:00 2001 From: jayvirsinh_gohil Date: Tue, 12 Nov 2019 18:30:17 +0530 Subject: [PATCH] add previous status method in invoice model --- app/Invoice.php | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/app/Invoice.php b/app/Invoice.php index 0bbd845a..31a1425e 100644 --- a/app/Invoice.php +++ b/app/Invoice.php @@ -113,6 +113,19 @@ class Invoice extends Model return $this->belongsTo(InvoiceTemplate::class); } + public function getPreviousStatus() + { + if ($this->due_date < Carbon::now()) { + return self::STATUS_OVERDUE; + } elseif ($this->viewed) { + return self::STATUS_VIEWED; + } elseif ($this->sent) { + return self::STATUS_SENT; + } else { + return self::STATUS_DRAFT; + } + } + private function strposX($haystack, $needle, $number) { if ($number == '1') {