From d30ef031a298947c0c1a11d6c0d55a762dc369c3 Mon Sep 17 00:00:00 2001 From: David Bomba Date: Thu, 3 Dec 2020 15:30:32 +1100 Subject: [PATCH] refactor invoice deletion --- app/Repositories/InvoiceRepository.php | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/app/Repositories/InvoiceRepository.php b/app/Repositories/InvoiceRepository.php index f55827cb99..afa11a0e3e 100644 --- a/app/Repositories/InvoiceRepository.php +++ b/app/Repositories/InvoiceRepository.php @@ -77,11 +77,23 @@ class InvoiceRepository extends BaseRepository return $invoice; } - public function restore() :Invoice + /** + * Handles the restoration on a deleted invoice. + * + * @param [type] $invoice [description] + * @return [type] [description] + */ + public function restore($invoice) :Invoice { - if(!$invoice->is_deleted) - return $invoice + //if we have just archived, only perform a soft restore + if(!$invoice->is_deleted) { + parent::restore($invoice); + + return $invoice; + } + + // reversed delete invoice actions $invoice = $invoice->service()->handeRestore()->save() parent::restore($invoice);