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 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 ExceptionHandler
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.

View file

@ -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 ImageUploadRequest
parent::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;
}