From 447dfc1f8c45904de8b387a52834535a09c93617 Mon Sep 17 00:00:00 2001 From: David Bomba Date: Sat, 12 Feb 2022 11:17:36 +1100 Subject: [PATCH] Forward user to quote on conversion --- app/Http/Controllers/ClientPortal/QuoteController.php | 5 +++++ app/Models/Quote.php | 8 ++++---- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/app/Http/Controllers/ClientPortal/QuoteController.php b/app/Http/Controllers/ClientPortal/QuoteController.php index 381221e39863..03b0a648af39 100644 --- a/app/Http/Controllers/ClientPortal/QuoteController.php +++ b/app/Http/Controllers/ClientPortal/QuoteController.php @@ -183,6 +183,11 @@ class QuoteController extends Controller } if(count($ids) == 1){ + + //forward client to the invoice if it exists + if($quote->invoice()->exists()) + return redirect()->route('client.invoice.show', $quote->invoice->hashed_id); + return redirect()->route('client.quote.show', $quotes->first()->hashed_id); } diff --git a/app/Models/Quote.php b/app/Models/Quote.php index b627cb5a267c..a1e57d2fdc6b 100644 --- a/app/Models/Quote.php +++ b/app/Models/Quote.php @@ -159,10 +159,10 @@ class Quote extends BaseModel return $this->belongsTo(Client::class)->withTrashed(); } - // public function contacts() - // { - // return $this->hasManyThrough(ClientContact::class, Client::class); - // } + public function invoice() + { + return $this->belongsTo(Invoice::class)->withTrashed(); + } public function assigned_user() {