From 24f8175c2a0a73d8e6647fda11602a0c81da446a Mon Sep 17 00:00:00 2001 From: jayvirsinh_gohil Date: Fri, 15 Nov 2019 18:24:42 +0530 Subject: [PATCH] refactor send invoice and estimate --- app/Http/Controllers/EstimatesController.php | 4 ++-- app/Http/Controllers/InvoicesController.php | 3 ++- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/app/Http/Controllers/EstimatesController.php b/app/Http/Controllers/EstimatesController.php index 790502d1..706a50a1 100644 --- a/app/Http/Controllers/EstimatesController.php +++ b/app/Http/Controllers/EstimatesController.php @@ -328,13 +328,13 @@ class EstimatesController extends Controller ]); } + \Mail::to($email)->send(new EstimatePdf($data, $notificationEmail)); + if ($estimate->status == Estimate::STATUS_DRAFT) { $estimate->status = Estimate::STATUS_SENT; $estimate->save(); } - \Mail::to($email)->send(new EstimatePdf($data, $notificationEmail)); - return response()->json([ 'success' => true ]); diff --git a/app/Http/Controllers/InvoicesController.php b/app/Http/Controllers/InvoicesController.php index 54a8d764..13415b36 100644 --- a/app/Http/Controllers/InvoicesController.php +++ b/app/Http/Controllers/InvoicesController.php @@ -392,13 +392,14 @@ class InvoicesController extends Controller ]); } + \Mail::to($email)->send(new invoicePdf($data, $notificationEmail)); + if ($invoice->status == Invoice::STATUS_DRAFT) { $invoice->status = Invoice::STATUS_SENT; $invoice->sent = true; $invoice->save(); } - \Mail::to($email)->send(new invoicePdf($data, $notificationEmail)); return response()->json([ 'success' => true