app/API/Strings/Requests/Request.php
/**
     * Override FormRequest's response() method to return our own response for validation errors.
     *
     * @param array $errors
     *
     * @return \Illuminate\Http\JsonResponse
     */
Override FormRequest's response() method to return our own response for validation errors.
@param array $errors


Override FormRequest ' s response () method to return our own response for validation errors . @param array $errors
public function response(array $errors)
    {
        $payload = ['errors' => []];
        foreach ($errors as $field => $message) {
            $payload['errors'][] = [
                'field' => $field,
                'message' => $message[0]
            ];
        }
        return response()->json($payload, 422);
    }
public function response ( array $ errors ) { $ payload = [ 'errors' => [ ] ] ; foreach ( $ errors as $ field => $ message ) { $ payload [ 'errors' ] [ ] = [ 'field' => $ field , 'message' => $ message [ 0 ] ] ; } return response ( ) -> json ( $ payload , 422 ) ; }
Override FormRequest's response() method to return our own response for validation errors.
Override FormRequest ' s response () method to return our own response for validation errors .