A free open source IT asset/license management system
License checkout controller with route model binding
snipe22c58678c469
diff --git a/app/Http/Controllers/Licenses/LicenseCheckoutController.php b/app/Http/Controllers/Licenses/LicenseCheckoutController.phpindex 0f31db1449..564ce97a89 100644--- a/app/Http/Controllers/Licenses/LicenseCheckoutController.php+++ b/app/Http/Controllers/Licenses/LicenseCheckoutController.php@@ -28,33 +28,24 @@ class LicenseCheckoutController extends Controller* @return \Illuminate\Contracts\View\View* @throws \Illuminate\Auth\Access\AuthorizationException*/- public function create($id)+ public function create(License $license){+ $this->authorize('checkout', $license);- if ($license = License::find($id)) {-- $this->authorize('checkout', $license);-- if ($license->category) {-- // Make sure there is at least one available to checkout- if ($license->availCount()->count() < 1){- return redirect()->route('licenses.index')->with('error', trans('admin/licenses/message.checkout.not_enough_seats'));- }+ if ($license->category) {- // Return the checkout view- return view('licenses/checkout', compact('license'));+ // Make sure there is at least one available to checkout+ if ($license->availCount()->count() < 1) {+ return redirect()->route('licenses.index')->with('error', trans('admin/licenses/message.checkout.not_enough_seats'));}- // Invalid category- return redirect()->route('licenses.edit', ['license' => $license->id])- ->with('error', trans('general.invalid_item_category_single', ['type' => trans('general.license')]));-+ // Return the checkout view+ return view('licenses/checkout', compact('license'));}- // Not found- return redirect()->route('licenses.index')->with('error', trans('admin/licenses/message.not_found'));-+ // Invalid category+ return redirect()->route('licenses.edit', ['license' => $license->id])+ ->with('error', trans('general.invalid_item_category_single', ['type' => trans('general.license')]));}