this works, need to write up pr

This commit is contained in:
spencerrlongg 2023-11-01 11:33:29 -05:00
parent b67b00dd82
commit 53bd5626c9
2 changed files with 9 additions and 5 deletions

View file

@ -4,6 +4,7 @@ namespace App\Exceptions;
use Illuminate\Foundation\Exceptions\Handler as ExceptionHandler; use Illuminate\Foundation\Exceptions\Handler as ExceptionHandler;
use App\Helpers\Helper; use App\Helpers\Helper;
use Illuminate\Http\JsonResponse;
use Illuminate\Validation\ValidationException; use Illuminate\Validation\ValidationException;
use Illuminate\Auth\AuthenticationException; use Illuminate\Auth\AuthenticationException;
use ArieTimmerman\Laravel\SCIMServer\Exceptions\SCIMException; use ArieTimmerman\Laravel\SCIMServer\Exceptions\SCIMException;
@ -150,6 +151,11 @@ class Handler extends ExceptionHandler
return redirect()->guest('login'); return 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. * A list of the inputs that are never flashed for validation exceptions.

View file

@ -15,8 +15,8 @@ class StoreAssetRequest extends ImageUploadRequest
*/ */
public function authorize(): bool public function authorize(): bool
{ {
//TODO: make sure this works // TODO: make sure this works
//return Gate::allows('create', new Asset); return Gate::allows('create', new Asset);
} }
public function prepareForValidation(): void public function prepareForValidation(): void
@ -36,13 +36,11 @@ class StoreAssetRequest extends ImageUploadRequest
parent::rules(), parent::rules(),
); );
if(!$this->expectsJson()) { // unsets unique check here, that check cannot run twice.
//accepts an array for the gui form
$rules['asset_tags.*'] = $rules['asset_tag']; $rules['asset_tags.*'] = $rules['asset_tag'];
unset($rules['asset_tag']); unset($rules['asset_tag']);
$rules['serials.*'] = $rules['serial']; $rules['serials.*'] = $rules['serial'];
unset($rules['serial']); unset($rules['serial']);
}
return $rules; return $rules;
} }