Skip to content

A free open source IT asset/license management system

immutable

spencerrlongg7c9a4ac161fd
diff --git a/database/migrations/2023_07_13_052204_denormalized_eol_and_add_column_for_explicit_date_to_assets.php b/database/migrations/2023_07_13_052204_denormalized_eol_and_add_column_for_explicit_date_to_assets.php
index 04c1e70f99..ddcf96bb79 100644
--- a/database/migrations/2023_07_13_052204_denormalized_eol_and_add_column_for_explicit_date_to_assets.php
+++ b/database/migrations/2023_07_13_052204_denormalized_eol_and_add_column_for_explicit_date_to_assets.php
@@ -1,7 +1,7 @@
<?php
use App\Models\Asset;
-use Carbon\Carbon;
+use Carbon\CarbonImmutable;
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
@@ -24,7 +24,7 @@ class DenormalizedEolAndAddColumnForExplicitDateToAssets extends Migration
Asset::whereNotNull('asset_eol_date')->chunk(100, function ($assetsWithEolDates) {
foreach ($assetsWithEolDates as $asset) {
if ($asset->asset_eol_date && $asset->purchase_date) {
- $months = Carbon::parse($asset->asset_eol_date)->diffInMonths($asset->purchase_date);
+ $months = CarbonImmutable::parse($asset->asset_eol_date)->diffInMonths($asset->purchase_date);
if ($asset->model->eol) {
if ($months != $asset->model->eol) {
$asset->update(['eol_explicit' => true]);
@@ -41,7 +41,7 @@ class DenormalizedEolAndAddColumnForExplicitDateToAssets extends Migration
foreach ($assets as $asset) {
$model = Asset::find($asset->id)->model;
if (!empty($model->eol)) {
- $asset_eol_date = Carbon::parse($asset->purchase_date)->addMonths($model->eol)->format('Y-m-d');
+ $asset_eol_date = CarbonImmutable::parse($asset->purchase_date)->addMonths($model->eol)->format('Y-m-d');
$asset->update(['asset_eol_date' => $asset_eol_date]);
}
}