mirror of
https://github.com/snipe/snipe-it.git
synced 2024-11-09 23:24:06 -08:00
Better handle the logic to determine if we should display the license checkout blade
This commit is contained in:
parent
beae8efb21
commit
2ac1c1636c
|
@ -246,17 +246,23 @@ class LicensesController extends Controller
|
|||
*/
|
||||
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'));
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Reference in a new issue