Skip to content

Commit

Permalink
Corrected license seat count associated with license. Fixes #75
Browse files Browse the repository at this point in the history
  • Loading branch information
snipe committed Nov 27, 2013
1 parent 6552401 commit 012a889
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
14 changes: 10 additions & 4 deletions app/controllers/admin/LicensesController.php
Original file line number Diff line number Diff line change
Expand Up @@ -201,17 +201,23 @@ public function getDelete($licenseId)
// Check if the license exists
if (is_null($license = License::find($licenseId)))
{
// Redirect to the blogs management page
// Redirect to the license management page
return Redirect::to('admin/licenses')->with('error', Lang::get('admin/licenses/message.not_found'));
}

if (count($license->assignedusers) > 0) {
// Redirect to the asset management page
if (($license->assignedcount()) && ($license->assignedcount() > 0)) {

// Redirect to the license management page
return Redirect::to('admin/licenses')->with('error', Lang::get('admin/licenses/message.assoc_users'));

} else {
// Delete the license

// Delete the license and the associated license seats
$licenseseats = $license->licenseseats();
$licenseseats->delete();
$license->delete();


// Redirect to the licenses management page
return Redirect::to('admin/licenses')->with('success', Lang::get('admin/licenses/message.delete.success'));
}
Expand Down
1 change: 1 addition & 0 deletions app/models/LicenseSeat.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

class LicenseSeat extends Elegant {
protected $table = 'license_seats';
protected $softDelete = true;

public function license()
{
Expand Down

0 comments on commit 012a889

Please sign in to comment.