Skip to content

A free open source IT asset/license management system

not all working, but pushing to work on something else

spencerrlonggeac01868caa0
diff --git a/app/Http/Controllers/Api/AssetsController.php b/app/Http/Controllers/Api/AssetsController.php
index 0f3bff3949..ec8e65e5c6 100644
--- a/app/Http/Controllers/Api/AssetsController.php
+++ b/app/Http/Controllers/Api/AssetsController.php
@@ -622,10 +622,9 @@ class AssetsController extends Controller
* @since [v4.0]
* @return \Illuminate\Http\JsonResponse
*/
- public function update(UpdateAssetRequest $request, Asset $id)
+ public function update(UpdateAssetRequest $request, Asset $asset)
{
- if ($asset = Asset::find($id)) {
- $asset->fill($request->validated());
+ $asset->update($request->validated());
// TODO: how much of this should go to validator?
($request->filled('model_id')) ?
@@ -689,11 +688,8 @@ class AssetsController extends Controller
}
return response()->json(Helper::formatStandardApiResponse('error', null, $asset->getErrors()), 200);
- }
- // TODO: can this be moved up to ModelNotFound exception handler? would remove a couple lines here if we could use laravel's awesome route-model binding.
- // (would also need to confirm that then _everything_ expects a 200 when a model isn't found)
- return response()->json(Helper::formatStandardApiResponse('error', null, trans('admin/hardware/message.does_not_exist')), 200);
+ // TODO: confirm that everything expects a _200_ model not found exception
}
diff --git a/app/Http/Requests/UpdateAssetRequest.php b/app/Http/Requests/UpdateAssetRequest.php
index 3c5286a1ce..f33f2d075a 100644
--- a/app/Http/Requests/UpdateAssetRequest.php
+++ b/app/Http/Requests/UpdateAssetRequest.php
@@ -3,7 +3,6 @@
namespace App\Http\Requests;
use App\Models\Asset;
-use Illuminate\Foundation\Http\FormRequest;
use Illuminate\Support\Facades\Gate;
class UpdateAssetRequest extends ImageUploadRequest
@@ -20,6 +19,10 @@ class UpdateAssetRequest extends ImageUploadRequest
public function prepareForValidation()
{
+ dump($this->asset);
+ $asset = $this->route('asset');
+ dump($asset);
+ dump($this->route()->getName());
// the following are 'required' attributes that may or may not be present on an patch request
// so supplying them here instead of doing funky array modification to the rules
if (!$this->has('asset_tag')) {