Skip to content

Commit

Permalink
Merge pull request #8141 from snipe/fixes/better_handling_when_licens…
Browse files Browse the repository at this point in the history
…e_is_invalid

Better handle the logic to determine if we should display the license checkout blade [ch13792]
  • Loading branch information
snipe authored Jun 17, 2020
2 parents beae8ef + 2ac1c16 commit 9a2440d
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions app/Http/Controllers/LicensesController.php
Original file line number Diff line number Diff line change
Expand Up @@ -246,17 +246,23 @@ public function destroy($licenseId)
*/
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'));



}


Expand Down

0 comments on commit 9a2440d

Please sign in to comment.