Corrected license seat count associated with license. Fixes #75

This commit is contained in:
snipe
2013-11-27 14:13:29 -05:00
parent 6552401fd8
commit 012a889444
2 changed files with 11 additions and 4 deletions
+10 -4
View File
@@ -201,17 +201,23 @@ class LicensesController extends AdminController {
// 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'));
}
+1
View File
@@ -2,6 +2,7 @@
class LicenseSeat extends Elegant {
protected $table = 'license_seats';
protected $softDelete = true;
public function license()
{