A free open source IT asset/license management system
this works, need to write up pr
spencerrlongg53bd5626c9e3
diff --git a/app/Exceptions/Handler.php b/app/Exceptions/Handler.phpindex 3d4db93452..b3317ad2df 100644--- a/app/Exceptions/Handler.php+++ b/app/Exceptions/Handler.php@@ -4,6 +4,7 @@ namespace App\Exceptions;use Illuminate\Foundation\Exceptions\Handler as ExceptionHandler;use App\Helpers\Helper;+use Illuminate\Http\JsonResponse;use Illuminate\Validation\ValidationException;use Illuminate\Auth\AuthenticationException;use ArieTimmerman\Laravel\SCIMServer\Exceptions\SCIMException;@@ -150,6 +151,11 @@ class Handler extends ExceptionHandlerreturn redirect()->guest('login');}+ protected function invalidJson($request, ValidationException $exception)+ {+ return response()->json(Helper::formatStandardApiResponse('error', null, $exception->errors()), 200);+ }+/*** A list of the inputs that are never flashed for validation exceptions.diff --git a/app/Http/Requests/StoreAssetRequest.php b/app/Http/Requests/StoreAssetRequest.phpindex 992d67e25b..a9a06baed4 100644--- a/app/Http/Requests/StoreAssetRequest.php+++ b/app/Http/Requests/StoreAssetRequest.php@@ -15,8 +15,8 @@ class StoreAssetRequest extends ImageUploadRequest*/public function authorize(): bool{- //TODO: make sure this works- //return Gate::allows('create', new Asset);+ // TODO: make sure this works+ return Gate::allows('create', new Asset);}public function prepareForValidation(): void@@ -36,13 +36,11 @@ class StoreAssetRequest extends ImageUploadRequestparent::rules(),);- if(!$this->expectsJson()) {- //accepts an array for the gui form+ // unsets unique check here, that check cannot run twice.$rules['asset_tags.*'] = $rules['asset_tag'];unset($rules['asset_tag']);$rules['serials.*'] = $rules['serial'];unset($rules['serial']);- }return $rules;}