mirror of
https://github.com/snipe/snipe-it.git
synced 2024-09-20 07:47:41 -07:00
Update AssetModelsController.php
if EOL of model has been changed and value is >0 assets will be updates with new EOL rate, date if EOL of model has been changes and value is null or 0 then assets will be updates by null EOL rate, date *asset with set expilicity market will not be updated
This commit is contained in:
parent
38066bf162
commit
58062ff9f5
|
@ -179,9 +179,14 @@ class AssetModelsController extends Controller
|
|||
|
||||
if ($model->save()) {
|
||||
if ($model->wasChanged('eol')) {
|
||||
$newEol = $model->eol;
|
||||
$model->assets()->whereNotNull('purchase_date')->where('eol_explicit', false)
|
||||
->update(['asset_eol_date' => DB::raw('DATE_ADD(purchase_date, INTERVAL ' . $newEol . ' MONTH)')]);
|
||||
if ($model->eol > 0) {
|
||||
$newEol = $model->eol;
|
||||
$model->assets()->whereNotNull('purchase_date')->where('eol_explicit', false)
|
||||
->update(['asset_eol_date' => DB::raw('DATE_ADD(purchase_date, INTERVAL ' . $newEol . ' MONTH)')]);
|
||||
} elseif ($model->eol == 0) {
|
||||
$model->assets()->whereNotNull('purchase_date')->where('eol_explicit', false)
|
||||
->update(['asset_eol_date' => DB::raw('null')]);
|
||||
}
|
||||
}
|
||||
return redirect()->route('models.index')->with('success', trans('admin/models/message.update.success'));
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue