From f75917d34d9340e9db51ecaaf5f29289d96754e7 Mon Sep 17 00:00:00 2001 From: Ivan Nieto Vivanco Date: Tue, 20 Sep 2022 17:53:55 -0500 Subject: [PATCH 1/5] Add a link used to clear the purchase date input --- resources/views/partials/forms/edit/purchase_date.blade.php | 1 + 1 file changed, 1 insertion(+) diff --git a/resources/views/partials/forms/edit/purchase_date.blade.php b/resources/views/partials/forms/edit/purchase_date.blade.php index 437a8ba6b..7cc3b7f54 100644 --- a/resources/views/partials/forms/edit/purchase_date.blade.php +++ b/resources/views/partials/forms/edit/purchase_date.blade.php @@ -6,6 +6,7 @@ + Clear {!! $errors->first('purchase_date', '') !!} From c32676596cf5df9d2910925daac943de7420785d Mon Sep 17 00:00:00 2001 From: Ivan Nieto Vivanco Date: Tue, 20 Sep 2022 18:55:53 -0500 Subject: [PATCH 2/5] Redirect correctly if not enough license seats exists to be checkout --- .../Licenses/LicenseCheckoutController.php | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/app/Http/Controllers/Licenses/LicenseCheckoutController.php b/app/Http/Controllers/Licenses/LicenseCheckoutController.php index e5a3b9894..dcf5a5a71 100644 --- a/app/Http/Controllers/Licenses/LicenseCheckoutController.php +++ b/app/Http/Controllers/Licenses/LicenseCheckoutController.php @@ -60,7 +60,9 @@ class LicenseCheckoutController extends Controller $this->authorize('checkout', $license); $licenseSeat = $this->findLicenseSeatToCheckout($license, $seatId); + dd($licenseSeat); $licenseSeat->user_id = Auth::id(); + $checkoutMethod = 'checkoutTo'.ucwords(request('checkout_to_type')); if ($this->$checkoutMethod($licenseSeat)) { @@ -74,16 +76,21 @@ class LicenseCheckoutController extends Controller { $licenseSeat = LicenseSeat::find($seatId) ?? $license->freeSeat(); + if(is_null($licenseSeat)){ + throw new \Illuminate\Http\Exceptions\HttpResponseException(redirect()->route('licenses.index')->with('error', 'This Seat is not available for checkout.')); + + } + if (! $licenseSeat) { if ($seatId) { - return redirect()->route('licenses.index')->with('error', 'This Seat is not available for checkout.'); + throw new \Illuminate\Http\Exceptions\HttpResponseException(redirect()->route('licenses.index')->with('error', 'This Seat is not available for checkout.')); } - - return redirect()->route('licenses.index')->with('error', 'There are no available seats for this license'); + + throw new \Illuminate\Http\Exceptions\HttpResponseException(redirect()->route('licenses.index')->with('error', 'There are no available seats for this license.')); } if (! $licenseSeat->license->is($license)) { - return redirect()->route('licenses.index')->with('error', 'The license seat provided does not match the license.'); + throw new \Illuminate\Http\Exceptions\HttpResponseException(redirect()->route('licenses.index')->with('error', 'The license seat provided does not match the license.')); } return $licenseSeat; From 5a1062f0f42f44b32c750cb422babb55bc830e8e Mon Sep 17 00:00:00 2001 From: Ivan Nieto Vivanco Date: Tue, 20 Sep 2022 18:58:31 -0500 Subject: [PATCH 3/5] Delete debugging symbols (just kidding, it's just a dd() function) --- app/Http/Controllers/Licenses/LicenseCheckoutController.php | 1 - 1 file changed, 1 deletion(-) diff --git a/app/Http/Controllers/Licenses/LicenseCheckoutController.php b/app/Http/Controllers/Licenses/LicenseCheckoutController.php index dcf5a5a71..62e4695d2 100644 --- a/app/Http/Controllers/Licenses/LicenseCheckoutController.php +++ b/app/Http/Controllers/Licenses/LicenseCheckoutController.php @@ -60,7 +60,6 @@ class LicenseCheckoutController extends Controller $this->authorize('checkout', $license); $licenseSeat = $this->findLicenseSeatToCheckout($license, $seatId); - dd($licenseSeat); $licenseSeat->user_id = Auth::id(); From c0f83a7927c04d42932454f04b91fe3c378a0da1 Mon Sep 17 00:00:00 2001 From: Ivan Nieto Vivanco Date: Tue, 20 Sep 2022 19:02:01 -0500 Subject: [PATCH 4/5] Delete not necessary conditional --- app/Http/Controllers/Licenses/LicenseCheckoutController.php | 5 ----- 1 file changed, 5 deletions(-) diff --git a/app/Http/Controllers/Licenses/LicenseCheckoutController.php b/app/Http/Controllers/Licenses/LicenseCheckoutController.php index 62e4695d2..6f2ae003c 100644 --- a/app/Http/Controllers/Licenses/LicenseCheckoutController.php +++ b/app/Http/Controllers/Licenses/LicenseCheckoutController.php @@ -75,11 +75,6 @@ class LicenseCheckoutController extends Controller { $licenseSeat = LicenseSeat::find($seatId) ?? $license->freeSeat(); - if(is_null($licenseSeat)){ - throw new \Illuminate\Http\Exceptions\HttpResponseException(redirect()->route('licenses.index')->with('error', 'This Seat is not available for checkout.')); - - } - if (! $licenseSeat) { if ($seatId) { throw new \Illuminate\Http\Exceptions\HttpResponseException(redirect()->route('licenses.index')->with('error', 'This Seat is not available for checkout.')); From 23cf556a8ba0e39546a09a9cf9c1182bfa885f6d Mon Sep 17 00:00:00 2001 From: Ivan Nieto Vivanco Date: Tue, 20 Sep 2022 22:24:52 -0500 Subject: [PATCH 5/5] Adds cursor:pointer to indicate a clickable link --- resources/views/partials/forms/edit/purchase_date.blade.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/resources/views/partials/forms/edit/purchase_date.blade.php b/resources/views/partials/forms/edit/purchase_date.blade.php index 7cc3b7f54..a232f8ef7 100644 --- a/resources/views/partials/forms/edit/purchase_date.blade.php +++ b/resources/views/partials/forms/edit/purchase_date.blade.php @@ -6,7 +6,7 @@ - Clear + Clear {!! $errors->first('purchase_date', '') !!}