mirror of
https://github.com/snipe/snipe-it.git
synced 2025-02-21 03:15:45 -08:00
immutable
This commit is contained in:
parent
64a9859efd
commit
7c9a4ac161
|
@ -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]);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue