diff --git a/app/Console/Commands/RemoveExplicitEols.php b/app/Console/Commands/RemoveExplicitEols.php new file mode 100644 index 000000000..f5164c2ee --- /dev/null +++ b/app/Console/Commands/RemoveExplicitEols.php @@ -0,0 +1,60 @@ +option('model_name') == 'all') { + $assets = Asset::all(); + $this->updateAssets($assets); + } else { + $assetModel = AssetModel::where('name', '=', $this->option('model_name'))->first(); + + if ($assetModel) { + $assets = Asset::where('model_id', '=', $assetModel->id)->get(); + $this->updateAssets($assets); + } else { + $this->error('Asset model not found'); + } + } + $endTime = microtime(true); + $executionTime = ($endTime - $startTime); + $this->info('Command executed in ' . round($executionTime, 2) . ' seconds.'); + } + + private function updateAssets($assets) + { + foreach ($assets as $asset) { + $asset->eol_explicit = 0; + $asset->asset_eol_date = null; + $asset->save(); + } + + $this->info($assets->count() . ' Assets updated successfully'); + } +}