diff --git a/app/Http/Controllers/Api/AssetsController.php b/app/Http/Controllers/Api/AssetsController.php index 4361dc40d8..bc415c0f3d 100644 --- a/app/Http/Controllers/Api/AssetsController.php +++ b/app/Http/Controllers/Api/AssetsController.php @@ -631,12 +631,12 @@ class AssetsController extends Controller // it actually breaks at the model validation if it gets to null... ($request->validated()['model_id']) ? $asset->model()->associate(AssetModel::find($request->validated()['model_id'])) : null; - ($request->validated()['rtd_location_id']) ? - $asset->location_id = $request->validated()['rtd_location_id'] : ''; - ($request->validated()['company_id']) ? - $asset->company_id = Company::getIdForCurrentUser($request->validated()['company_id']) : ''; - ($request->validated()['rtd_location_id']) ? - $asset->location_id = $request->validated()['rtd_location_id'] : null; + //($request->validated()['rtd_location_id']) ? + // $asset->location_id = $request->validated()['rtd_location_id'] : ''; + //($request->validated()['company_id']) ? + // $asset->company_id = Company::getIdForCurrentUser($request->validated()['company_id']) : ''; + //($request->validated()['rtd_location_id']) ? + // $asset->location_id = $request->validated()['rtd_location_id'] : null; /** * this is here just legacy reasons. Api\AssetController diff --git a/app/Models/Asset.php b/app/Models/Asset.php index 2e03323d38..303624b427 100644 --- a/app/Models/Asset.php +++ b/app/Models/Asset.php @@ -115,12 +115,15 @@ class Asset extends Depreciable public function getRulesAttribute() { - $rule = Rule::unique('assets')->ignore($this->id)->withoutTrashed(); - $asset = $this->id; 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', 'asset_tag')->ignore($this->id, 'id')->withoutTrashed()], + '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', diff --git a/tests/Feature/Api/Assets/AssetStoreTest.php b/tests/Feature/Api/Assets/AssetStoreTest.php index 92a58a5006..631944190d 100644 --- a/tests/Feature/Api/Assets/AssetStoreTest.php +++ b/tests/Feature/Api/Assets/AssetStoreTest.php @@ -149,9 +149,11 @@ class AssetStoreTest extends TestCase 'purchase_date' => '2021-01-01', 'status_id' => $status->id, ]) + //->dd() ->assertOk() ->assertStatusMessageIs('success') ->json(); + return $response; $asset = Asset::find($response['payload']['id']); $this->assertEquals('2024-01-01', $asset->asset_eol_date);