From 79ed18d9ff9a7f8c3bb8a8a54fc5051b5fe6980f Mon Sep 17 00:00:00 2001 From: David Bomba Date: Thu, 9 May 2019 08:47:38 +1000 Subject: [PATCH] invoice repo doc --- app/Repositories/InvoiceRepository.php | 37 +++++++++++++++++++++++++- 1 file changed, 36 insertions(+), 1 deletion(-) diff --git a/app/Repositories/InvoiceRepository.php b/app/Repositories/InvoiceRepository.php index 8cfc4218ca8d..8b26b876d779 100644 --- a/app/Repositories/InvoiceRepository.php +++ b/app/Repositories/InvoiceRepository.php @@ -13,12 +13,26 @@ class InvoiceRepository extends BaseRepository { + /** + * Gets the class name. + * + * @return ::class The class name. + */ public function getClassName() { return Invoice::class; } + - public function save($data, Invoice $invoice) : ?Invoice + /** + * Saves the invoices + * + * @param array. $data The invoice data + * @param InvoiceCalc|\App\Models\Invoice $invoice The invoice + * + * @return Invoice|InvoiceCalc|\App\Models\Invoice|null Returns the invoice object + */ + public function save($data, Invoice $invoice) : ?Invoice { $invoice->fill($data); @@ -35,4 +49,25 @@ class InvoiceRepository extends BaseRepository return $invoice; } + + /** + * Mark the invoice as sent. + * + * @param \App\Models\Invoice $invoice The invoice + * + * @return Invoice|\App\Models\Invoice|null Return the invoice object + */ + public function markSent(Invoice $invoice) : ?Invoice + { + + if($invoice->status_id >= Invoice::STATUS_SENT) + return; + + $invoice->status_id = Invoice::STATUS_SENT; + $invoice->save(); + + return $invoice; + + } + } \ No newline at end of file