Skip to content

Commit

Permalink
Better handle the logic to determine if we should display the license…
Browse files Browse the repository at this point in the history
… checkout blade
  • Loading branch information
snipe committed Jun 16, 2020
1 parent beae8ef commit 2ac1c16
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 2ac1c16

Please sign in to comment.