From e3e01e07b14599b89c6de98b8d870d1dcaf9e409 Mon Sep 17 00:00:00 2001 From: spencerrlongg Date: Wed, 20 Mar 2024 15:23:45 -0500 Subject: [PATCH] final cleanup --- app/Models/Asset.php | 38 +------------------- app/Providers/ValidationServiceProvider.php | 16 --------- tests/Feature/Api/Assets/AssetStoreTest.php | 1 - tests/Feature/Api/Assets/AssetUpdateTest.php | 4 --- 4 files changed, 1 insertion(+), 58 deletions(-) diff --git a/app/Models/Asset.php b/app/Models/Asset.php index 3219e50e1..806ecbb0c 100644 --- a/app/Models/Asset.php +++ b/app/Models/Asset.php @@ -113,38 +113,6 @@ class Asset extends Depreciable '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. * @@ -244,12 +212,8 @@ class Asset extends Depreciable $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){ foreach ($this->model->fieldset->fields as $field){ diff --git a/app/Providers/ValidationServiceProvider.php b/app/Providers/ValidationServiceProvider.php index 172e99bf4..bf9f5c55c 100644 --- a/app/Providers/ValidationServiceProvider.php +++ b/app/Providers/ValidationServiceProvider.php @@ -63,7 +63,6 @@ class ValidationServiceProvider extends ServiceProvider * `unique_undeleted:table,fieldname` in your rules out of the box */ Validator::extend('unique_undeleted', function ($attribute, $value, $parameters, $validator) { - 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 @@ -79,21 +78,6 @@ class ValidationServiceProvider extends ServiceProvider 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; - //} }); /** diff --git a/tests/Feature/Api/Assets/AssetStoreTest.php b/tests/Feature/Api/Assets/AssetStoreTest.php index eee0da392..92a58a500 100644 --- a/tests/Feature/Api/Assets/AssetStoreTest.php +++ b/tests/Feature/Api/Assets/AssetStoreTest.php @@ -149,7 +149,6 @@ class AssetStoreTest extends TestCase 'purchase_date' => '2021-01-01', 'status_id' => $status->id, ]) - //->dd() ->assertOk() ->assertStatusMessageIs('success') ->json(); diff --git a/tests/Feature/Api/Assets/AssetUpdateTest.php b/tests/Feature/Api/Assets/AssetUpdateTest.php index 773ba97e9..369f967ad 100644 --- a/tests/Feature/Api/Assets/AssetUpdateTest.php +++ b/tests/Feature/Api/Assets/AssetUpdateTest.php @@ -85,10 +85,6 @@ class AssetUpdateTest extends TestCase $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('random_string', $updatedAsset->asset_tag); $this->assertEquals($userAssigned->id, $updatedAsset->assigned_to);