mirror of
https://github.com/snipe/snipe-it.git
synced 2024-12-24 05:04:07 -08:00
Merge pull request #8141 from snipe/fixes/better_handling_when_license_is_invalid
Better handle the logic to determine if we should display the license checkout blade [ch13792]
This commit is contained in:
commit
9a2440dc4b
|
@ -246,17 +246,23 @@ class LicensesController extends Controller
|
||||||
*/
|
*/
|
||||||
public function getCheckout($licenceId)
|
public function getCheckout($licenceId)
|
||||||
{
|
{
|
||||||
|
|
||||||
// Check that the license is valid
|
// Check that the license is valid
|
||||||
if ($license = License::where('id',$licenceId)->first()) {
|
if ($license = License::where('id',$licenceId)->first()) {
|
||||||
|
|
||||||
|
$this->authorize('checkout', $license);
|
||||||
|
|
||||||
// If the license is valid, check that there is an available seat
|
// If the license is valid, check that there is an available seat
|
||||||
if ($license->getAvailSeatsCountAttribute() < 1) {
|
if ($license->getAvailSeatsCountAttribute() < 1) {
|
||||||
return redirect()->route('licenses.index')->with('error', 'There are no available seats for this license');
|
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 redirect()->route('licenses.index')->with('error', trans('admin/licenses/message.does_not_exist'));
|
||||||
return view('licenses/checkout', compact('license'));
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue