Skip to content

A free open source IT asset/license management system

Merge branch 'develop' into bug/sc-24884

Spencer Longcdb1140f10e3
diff --cc app/Models/Asset.php
index 4df74659a2,f31b872841..05b4fe64a2
--- a/app/Models/Asset.php
+++ b/app/Models/Asset.php
@@@ -89,30 -89,31 +89,31 @@@ class Asset extends Depreciabl
];
protected $rules = [
- 'model_id' => 'required|integer|exists:models,id,deleted_at,NULL|not_array',
- 'status_id' => 'required|integer|exists:status_labels,id',
- 'asset_tag' => 'required|min:1|max:255|unique_undeleted:assets,asset_tag|not_array',
- 'name' => 'nullable|max:255',
- 'company_id' => 'nullable|integer|exists:companies,id',
- 'warranty_months' => 'nullable|numeric|digits_between:0,240',
- 'last_checkout' => 'nullable|date_format:Y-m-d H:i:s',
- 'last_checkin' => 'nullable|date_format:Y-m-d H:i:s',
- 'expected_checkin' => 'nullable|date',
- 'last_audit_date' => 'nullable|date_format:Y-m-d H:i:s',
- // 'next_audit_date' => 'nullable|date|after:last_audit_date',
- 'next_audit_date' => 'nullable|date',
- 'location_id' => 'nullable|exists:locations,id',
- 'rtd_location_id' => 'nullable|exists:locations,id',
- 'purchase_date' => 'nullable|date|date_format:Y-m-d',
- 'serial' => 'nullable|unique_undeleted:assets,serial',
- 'purchase_cost' => 'nullable|numeric|gte:0',
- 'supplier_id' => 'nullable|exists:suppliers,id',
- 'asset_eol_date' => 'nullable|date',
- 'eol_explicit' => 'nullable|boolean',
- 'byod' => 'nullable|boolean',
- 'order_number' => 'nullable|string|max:191',
- 'notes' => 'nullable|string|max:65535',
- 'assigned_to' => 'nullable|integer',
- 'requestable' => 'nullable|boolean',
+ 'model_id' => ['required', 'integer', 'exists:models,id,deleted_at,NULL', 'not_array'],
+ 'status_id' => ['required', 'integer', 'exists:status_labels,id'],
+ 'asset_tag' => ['required', 'min:1', 'max:255', 'unique_undeleted:assets,asset_tag', 'not_array'],
+ 'name' => ['nullable', 'max:255'],
+ 'company_id' => ['nullable', 'integer', 'exists:companies,id'],
+ 'warranty_months' => ['nullable', 'numeric', 'digits_between:0,240'],
+ 'last_checkout' => ['nullable', 'date_format:Y-m-d H:i:s'],
+ 'last_checkin' => ['nullable', 'date_format:Y-m-d H:i:s'],
+ 'expected_checkin' => ['nullable', 'date'],
+ 'last_audit_date' => ['nullable', 'date_format:Y-m-d H:i:s'],
- 'next_audit_date' => ['nullable', 'date', 'after:last_audit_date'],
++ 'next_audit_date' => ['nullable', 'date'],
++ //'after:last_audit_date'],
+ 'location_id' => ['nullable', 'exists:locations,id'],
+ 'rtd_location_id' => ['nullable', 'exists:locations,id'],
+ 'purchase_date' => ['nullable', 'date', 'date_format:Y-m-d'],
+ 'serial' => ['nullable', 'unique_undeleted:assets,serial'],
+ 'purchase_cost' => ['nullable', 'numeric', 'gte:0'],
+ 'supplier_id' => ['nullable', 'exists:suppliers,id'],
+ 'asset_eol_date' => ['nullable', 'date'],
+ 'eol_explicit' => ['nullable', 'boolean'],
+ 'byod' => ['nullable', 'boolean'],
+ 'order_number' => ['nullable', 'string', 'max:191'],
+ 'notes' => ['nullable', 'string', 'max:65535'],
+ 'assigned_to' => ['nullable', 'integer'],
+ 'requestable' => ['nullable', 'boolean'],
];
diff --cc database/factories/AssetFactory.php
index 970c196c95,43845c3075..a787ffb417
--- a/database/factories/AssetFactory.php
+++ b/database/factories/AssetFactory.php
@@@ -375,6 -363,16 +375,15 @@@ class AssetFactory extends Factor
});
}
+ public function hasMultipleCustomFields(array $fields = null): self
+ {
+ return $this->state(function () use ($fields) {
+ return [
+ 'model_id' => AssetModel::factory()->hasMultipleCustomFields($fields),
+ ];
+ });
+ }
+
-
/**
* This allows bypassing model level validation if you want to purposefully
* create an asset in an invalid state. Validation is turned back on