mirror of
https://github.com/snipe/snipe-it.git
synced 2025-01-12 14:27:33 -08:00
final cleanup
This commit is contained in:
parent
d18aa1db98
commit
e3e01e07b1
|
@ -113,38 +113,6 @@ class Asset extends Depreciable
|
||||||
'requestable' => 'nullable|boolean',
|
'requestable' => 'nullable|boolean',
|
||||||
];
|
];
|
||||||
|
|
||||||
//public function getRulesAttribute()
|
|
||||||
//{
|
|
||||||
// return [
|
|
||||||
// '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',
|
|
||||||
// Rule::unique('assets')->ignore(15)->withoutTrashed()
|
|
||||||
// ],
|
|
||||||
// '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',
|
|
||||||
// 'expected_checkin' => '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',
|
|
||||||
// ];
|
|
||||||
//}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The attributes that are mass assignable.
|
* The attributes that are mass assignable.
|
||||||
*
|
*
|
||||||
|
@ -244,12 +212,8 @@ class Asset extends Depreciable
|
||||||
$this->{$field->db_column} = filter_var($this->{$field->db_column}, FILTER_VALIDATE_BOOLEAN);
|
$this->{$field->db_column} = filter_var($this->{$field->db_column}, FILTER_VALIDATE_BOOLEAN);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$this->rules = array_merge(
|
|
||||||
$this->rules,
|
|
||||||
$model->fieldset->validation_rules(),
|
|
||||||
);
|
|
||||||
|
|
||||||
//$this->rules += $model->fieldset->validation_rules();
|
$this->rules += $model->fieldset->validation_rules();
|
||||||
|
|
||||||
if ($this->model->fieldset){
|
if ($this->model->fieldset){
|
||||||
foreach ($this->model->fieldset->fields as $field){
|
foreach ($this->model->fieldset->fields as $field){
|
||||||
|
|
|
@ -63,7 +63,6 @@ class ValidationServiceProvider extends ServiceProvider
|
||||||
* `unique_undeleted:table,fieldname` in your rules out of the box
|
* `unique_undeleted:table,fieldname` in your rules out of the box
|
||||||
*/
|
*/
|
||||||
Validator::extend('unique_undeleted', function ($attribute, $value, $parameters, $validator) {
|
Validator::extend('unique_undeleted', function ($attribute, $value, $parameters, $validator) {
|
||||||
|
|
||||||
if (count($parameters)) {
|
if (count($parameters)) {
|
||||||
|
|
||||||
// This is a bit of a shim, but serial doesn't have any other rules around it other than that it's nullable
|
// This is a bit of a shim, but serial doesn't have any other rules around it other than that it's nullable
|
||||||
|
@ -79,21 +78,6 @@ class ValidationServiceProvider extends ServiceProvider
|
||||||
|
|
||||||
return $count < 1;
|
return $count < 1;
|
||||||
}
|
}
|
||||||
//else {
|
|
||||||
// if (($parameters[0] == 'assets') && ($attribute == 'serial') && (Setting::getSettings()->unique_serial != '1')) {
|
|
||||||
// return true;
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// $count = DB::table($parameters[0])
|
|
||||||
// ->select('id')
|
|
||||||
// ->where($attribute, '=', $value)
|
|
||||||
// ->whereNull('deleted_at')
|
|
||||||
// ->where('id', '!=', $parameters[1])
|
|
||||||
// ->where('id', '!=', $parameters[2])
|
|
||||||
// ->count();
|
|
||||||
//
|
|
||||||
// return $count < 1;
|
|
||||||
//}
|
|
||||||
});
|
});
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -149,7 +149,6 @@ class AssetStoreTest extends TestCase
|
||||||
'purchase_date' => '2021-01-01',
|
'purchase_date' => '2021-01-01',
|
||||||
'status_id' => $status->id,
|
'status_id' => $status->id,
|
||||||
])
|
])
|
||||||
//->dd()
|
|
||||||
->assertOk()
|
->assertOk()
|
||||||
->assertStatusMessageIs('success')
|
->assertStatusMessageIs('success')
|
||||||
->json();
|
->json();
|
||||||
|
|
|
@ -85,10 +85,6 @@ class AssetUpdateTest extends TestCase
|
||||||
|
|
||||||
$updatedAsset = Asset::find($response['payload']['id']);
|
$updatedAsset = Asset::find($response['payload']['id']);
|
||||||
|
|
||||||
// TODO: this isn't working, i assume `adminuser` is the user that created asset
|
|
||||||
// maybe i don't need to test this on an update???
|
|
||||||
//$this->assertTrue($updatedAsset->adminuser->is($user));
|
|
||||||
|
|
||||||
$this->assertEquals('2024-06-02', $updatedAsset->asset_eol_date);
|
$this->assertEquals('2024-06-02', $updatedAsset->asset_eol_date);
|
||||||
$this->assertEquals('random_string', $updatedAsset->asset_tag);
|
$this->assertEquals('random_string', $updatedAsset->asset_tag);
|
||||||
$this->assertEquals($userAssigned->id, $updatedAsset->assigned_to);
|
$this->assertEquals($userAssigned->id, $updatedAsset->assigned_to);
|
||||||
|
|
Loading…
Reference in a new issue