mirror of
https://github.com/snipe/snipe-it.git
synced 2025-03-05 20:52:15 -08:00
Merge pull request #11857 from inietov/fixes/throw_exception_instead_of_redirect_when_no_available_licenseseats
Fixed #11827 Throw exception when there are no available seats for checkout.
This commit is contained in:
commit
d91d226652
|
@ -62,6 +62,7 @@ class LicenseCheckoutController extends Controller
|
||||||
$licenseSeat = $this->findLicenseSeatToCheckout($license, $seatId);
|
$licenseSeat = $this->findLicenseSeatToCheckout($license, $seatId);
|
||||||
$licenseSeat->user_id = Auth::id();
|
$licenseSeat->user_id = Auth::id();
|
||||||
|
|
||||||
|
|
||||||
$checkoutMethod = 'checkoutTo'.ucwords(request('checkout_to_type'));
|
$checkoutMethod = 'checkoutTo'.ucwords(request('checkout_to_type'));
|
||||||
if ($this->$checkoutMethod($licenseSeat)) {
|
if ($this->$checkoutMethod($licenseSeat)) {
|
||||||
return redirect()->route('licenses.index')->with('success', trans('admin/licenses/message.checkout.success'));
|
return redirect()->route('licenses.index')->with('success', trans('admin/licenses/message.checkout.success'));
|
||||||
|
@ -76,14 +77,14 @@ class LicenseCheckoutController extends Controller
|
||||||
|
|
||||||
if (! $licenseSeat) {
|
if (! $licenseSeat) {
|
||||||
if ($seatId) {
|
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)) {
|
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;
|
return $licenseSeat;
|
||||||
|
|
Loading…
Reference in a new issue