License checkout controller with route model binding

Signed-off-by: snipe <snipe@snipe.net>
This commit is contained in:
snipe 2025-02-19 08:38:55 +00:00
parent 4beaf6b3ec
commit 22c58678c4

View file

@ -28,17 +28,14 @@ class LicenseCheckoutController extends Controller
* @return \Illuminate\Contracts\View\View
* @throws \Illuminate\Auth\Access\AuthorizationException
*/
public function create($id)
public function create(License $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){
if ($license->availCount()->count() < 1) {
return redirect()->route('licenses.index')->with('error', trans('admin/licenses/message.checkout.not_enough_seats'));
}
@ -52,12 +49,6 @@ class LicenseCheckoutController extends Controller
}
// Not found
return redirect()->route('licenses.index')->with('error', trans('admin/licenses/message.not_found'));
}
/**
* Validates and stores the license checkout action.
*