fix last code for this part
This commit is contained in:
@@ -46,11 +46,21 @@ class ReceiveNewRequest extends FormRequest
|
||||
|
||||
protected function failedValidation(Validator $validator)
|
||||
{
|
||||
$response = response()->json([
|
||||
'statusCode' => 422,
|
||||
'message' => 'invalid inputs',
|
||||
'errors' => $validator->errors(),
|
||||
], 422);
|
||||
if ($validator->errors()->has('request_id') && str_contains($validator->errors()->first('request_id'), 'unique'))
|
||||
{
|
||||
$response = response()->json([
|
||||
'statusCode' => 201,
|
||||
'message' => 'already stored',
|
||||
], 201);
|
||||
}
|
||||
else
|
||||
{
|
||||
$response = response()->json([
|
||||
'statusCode' => 422,
|
||||
'message' => 'invalid inputs',
|
||||
'errors' => $validator->errors(),
|
||||
], 422);
|
||||
}
|
||||
|
||||
throw new HttpResponseException($response);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user