fix conflicts

This commit is contained in:
slong753 2023-07-18 08:10:58 -05:00 committed by spencerrlongg
parent cda9dd57dd
commit 20367eecc9
2 changed files with 13 additions and 8 deletions

View file

@ -84,9 +84,11 @@ class Asset extends Depreciable
'location_id' => 'integer', 'location_id' => 'integer',
'rtd_company_id' => 'integer', 'rtd_company_id' => 'integer',
'supplier_id' => 'integer', 'supplier_id' => 'integer',
'byod' => 'boolean',
'created_at' => 'datetime', 'created_at' => 'datetime',
'updated_at' => 'datetime', 'updated_at' => 'datetime',
'deleted_at' => 'datetime', 'deleted_at' => 'datetime',
'eol_explicit' => 'boolean',
]; ];
protected $rules = [ protected $rules = [
@ -105,7 +107,8 @@ class Asset extends Depreciable
'serial' => 'unique_serial|nullable', 'serial' => 'unique_serial|nullable',
'purchase_cost' => 'numeric|nullable|gte:0', 'purchase_cost' => 'numeric|nullable|gte:0',
'supplier_id' => 'exists:suppliers,id|nullable', 'supplier_id' => 'exists:suppliers,id|nullable',
'asset_eol_date' => 'date|max:10|min:10|nullable', 'asset_eol_date' => 'date_format:Y-m-d|nullable',
'eol_explicit' => 'boolean|nullable',
'byod' => 'boolean', 'byod' => 'boolean',
]; ];
@ -139,6 +142,7 @@ class Asset extends Depreciable
'asset_eol_date', 'asset_eol_date',
'last_audit_date', 'last_audit_date',
'next_audit_date', 'next_audit_date',
'eol_explicit',
]; ];
use Searchable; use Searchable;

View file

@ -16,18 +16,19 @@ class DenormalizedEolAndAddColumnForExplicitDateToAssets extends Migration
public function up() public function up()
{ {
Schema::table('assets', function (Blueprint $table) { Schema::table('assets', function (Blueprint $table) {
$table->date('eol_explicit')->after('asset_eol_date')->nullable(); $table->boolean('eol_explicit')->default(false)->after('asset_eol_date');
}); });
// Update the eol_explicit column with the value from asset_eol_date if it exists and is different from the calculated value // Update the eol_explicit column with the value from asset_eol_date if it exists and is different from the calculated value
$assetsWithEolDates = Asset::whereNotNull('asset_eol_date')->get(); $assetsWithEolDates = Asset::whereNotNull('asset_eol_date')->get();
foreach($assetsWithEolDates as $asset) { foreach($assetsWithEolDates as $asset) {
if($asset->asset_eol_date && $asset->asset_purchase_date) { if($asset->asset_eol_date && $asset->purchase_date) {
$months = Carbon::parse($asset->asset_eol_date)->diffInMonths($asset->asset_purchase_date); $months = Carbon::parse($asset->asset_eol_date)->diffInMonths($asset->purchase_date);
if($months != $asset->model->eol) { if($months != $asset->model->eol) {
Asset::find($asset->id)->update(['eol_explicit' => $asset->asset_eol_date]); $asset->update(['eol_explicit' => true]);
} }
} }
} }
@ -38,8 +39,8 @@ class DenormalizedEolAndAddColumnForExplicitDateToAssets extends Migration
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->purchase_date)->addMonths($eol)->format('Y-m-d');
Asset::fine($asset->id)->update(['asset_eol_date' => $asset_eol_date]); $asset->update(['asset_eol_date' => $asset_eol_date]);
} }
} }
} }
@ -53,7 +54,7 @@ class DenormalizedEolAndAddColumnForExplicitDateToAssets extends Migration
public function down() public function down()
{ {
Schema::table('assets', function (Blueprint $table) { Schema::table('assets', function (Blueprint $table) {
// $table->dropColumn('eol_explicit');
}); });
} }
} }