From 2ac1c1636c672db59d601bd5c73d4a8023533ec9 Mon Sep 17 00:00:00 2001 From: snipe Date: Tue, 16 Jun 2020 16:12:57 -0700 Subject: [PATCH] Better handle the logic to determine if we should display the license checkout blade --- app/Http/Controllers/LicensesController.php | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/app/Http/Controllers/LicensesController.php b/app/Http/Controllers/LicensesController.php index 5bae86fc778b..472d6dba3ce6 100755 --- a/app/Http/Controllers/LicensesController.php +++ b/app/Http/Controllers/LicensesController.php @@ -246,17 +246,23 @@ public function destroy($licenseId) */ public function getCheckout($licenceId) { + // Check that the license is valid if ($license = License::where('id',$licenceId)->first()) { + $this->authorize('checkout', $license); + // If the license is valid, check that there is an available seat if ($license->getAvailSeatsCountAttribute() < 1) { return redirect()->route('licenses.index')->with('error', 'There are no available seats for this license'); } + return view('licenses/checkout', compact('license')); } - $this->authorize('checkout', $license); - return view('licenses/checkout', compact('license')); + return redirect()->route('licenses.index')->with('error', trans('admin/licenses/message.does_not_exist')); + + + }