mirror of
https://github.com/snipe/snipe-it.git
synced 2025-02-02 08:21:09 -08:00
small changes
This commit is contained in:
parent
17a83129b9
commit
41b65bd9a2
|
@ -129,6 +129,10 @@ class AssetImporter extends ItemImporter
|
||||||
$item['eol_explicit'] = $this->item['eol_explicit'];
|
$item['eol_explicit'] = $this->item['eol_explicit'];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(($item['asset_eol_date'] == null) && ($item['eol_explicit'] == null) && ($asset->model->eol != null) && ($asset->asset_purchase_date != null)){
|
||||||
|
$asset->asset_eol_date = Carbon::parse($asset->asset_purchase_date)->addMonths($asset->model->eol)->format('Y-m-d');
|
||||||
|
}
|
||||||
|
|
||||||
if ($editingAsset) {
|
if ($editingAsset) {
|
||||||
$asset->update($item);
|
$asset->update($item);
|
||||||
} else {
|
} else {
|
||||||
|
@ -142,11 +146,6 @@ class AssetImporter extends ItemImporter
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(($item['asset_eol_date'] == null) && ($item['eol_explicit'] == null) && ($asset->model->eol != null) && ($asset->asset_purchase_date != null)){
|
|
||||||
$asset->asset_eol_date = Carbon::parse($asset->asset_purchase_date)->addMonths($asset->model->eol)->format('Y-m-d');
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
if ($asset->save()) {
|
if ($asset->save()) {
|
||||||
|
|
||||||
$asset->logCreate(trans('general.importer.import_note'));
|
$asset->logCreate(trans('general.importer.import_note'));
|
||||||
|
|
|
@ -2,10 +2,8 @@
|
||||||
|
|
||||||
use App\Models\Asset;
|
use App\Models\Asset;
|
||||||
use Carbon\Carbon;
|
use Carbon\Carbon;
|
||||||
use Carbon\CarbonInterval;
|
|
||||||
use Illuminate\Database\Migrations\Migration;
|
use Illuminate\Database\Migrations\Migration;
|
||||||
use Illuminate\Database\Schema\Blueprint;
|
use Illuminate\Database\Schema\Blueprint;
|
||||||
use Illuminate\Support\Facades\DB;
|
|
||||||
use Illuminate\Support\Facades\Schema;
|
use Illuminate\Support\Facades\Schema;
|
||||||
|
|
||||||
class DenormalizedEolAndAddColumnForExplicitDateToAssets extends Migration
|
class DenormalizedEolAndAddColumnForExplicitDateToAssets extends Migration
|
||||||
|
@ -28,20 +26,20 @@ class DenormalizedEolAndAddColumnForExplicitDateToAssets extends Migration
|
||||||
if($asset->asset_eol_date && $asset->asset_purchase_date) {
|
if($asset->asset_eol_date && $asset->asset_purchase_date) {
|
||||||
$months = Carbon::parse($asset->asset_eol_date)->diffInMonths($asset->asset_purchase_date);
|
$months = Carbon::parse($asset->asset_eol_date)->diffInMonths($asset->asset_purchase_date);
|
||||||
if($months != $asset->model->eol) {
|
if($months != $asset->model->eol) {
|
||||||
DB::table('assets')->find($asset->id)->update(['eol_explicit' => $asset->asset_eol_date]);
|
Asset::find($asset->id)->update(['eol_explicit' => $asset->asset_eol_date]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Update the asset_eol_date column with the calculated value if it doesn't exist
|
// Update the asset_eol_date column with the calculated value if it doesn't exist
|
||||||
$assets = DB::table('assets')->whereNull('asset_eol_date')->get();
|
$assets = Asset::whereNull('asset_eol_date')->get();
|
||||||
foreach ($assets as $asset) {
|
foreach ($assets as $asset) {
|
||||||
$model = Asset::find($asset->id)->model;
|
$model = Asset::find($asset->id)->model;
|
||||||
if ($model) {
|
if ($model) {
|
||||||
$eol = $model->eol;
|
$eol = $model->eol;
|
||||||
if ($eol) {
|
if ($eol) {
|
||||||
$asset_eol_date = Carbon::parse($asset->asset_purchase_date)->addMonths($eol)->format('Y-m-d');
|
$asset_eol_date = Carbon::parse($asset->asset_purchase_date)->addMonths($eol)->format('Y-m-d');
|
||||||
DB::table('assets')->where('id', $asset->id)->update(['asset_eol_date' => $asset_eol_date]);
|
Asset::fine($asset->id)->update(['asset_eol_date' => $asset_eol_date]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue