Include asset maintenances in purge

This commit is contained in:
snipe 2016-08-18 07:06:15 -07:00
parent 4419dc7434
commit be8049b41a

View file

@ -62,15 +62,19 @@ class Purge extends Command
$assetcount = $assets->count(); $assetcount = $assets->count();
$this->info($assets->count().' assets purged.'); $this->info($assets->count().' assets purged.');
$asset_assoc = 0; $asset_assoc = 0;
$asset_maintenances = 0;
foreach ($assets as $asset) { foreach ($assets as $asset) {
$this->info('- Asset "'.$asset->showAssetName().'" deleted.'); $this->info('- Asset "'.$asset->showAssetName().'" deleted.');
$asset_assoc += $asset->assetlog()->count(); $asset_assoc += $asset->assetlog()->count();
$asset->assetlog()->forceDelete(); $asset->assetlog()->forceDelete();
$asset_maintenances += $asset->assetmaintenances()->count();
$asset->assetmaintenances()->forceDelete();
$asset->forceDelete(); $asset->forceDelete();
} }
$this->info($asset_assoc.' corresponding log records purged.'); $this->info($asset_assoc.' corresponding log records purged.');
$this->info($asset_maintenances.' corresponding maintenance records purged.');
$locations = Location::whereNotNull('deleted_at')->withTrashed()->get(); $locations = Location::whereNotNull('deleted_at')->withTrashed()->get();
$this->info($locations->count().' locations purged.'); $this->info($locations->count().' locations purged.');