Skip to content

Commit b2169d4

Browse files
update
1 parent ca24154 commit b2169d4

File tree

2 files changed

+10
-11
lines changed

2 files changed

+10
-11
lines changed

src/Validator.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,10 @@ public function save($closure)
131131
{
132132
// if validation already failed, return stored JsonResponse
133133
if ($this->jsonResponse instanceof \Symfony\Component\HttpFoundation\JsonResponse) {
134+
// Send only if not in Laravel environment to avoid double sending
135+
if (!class_exists('Illuminate\Foundation\Application')) {
136+
$this->jsonResponse->send();
137+
}
134138
return $this->jsonResponse;
135139
}
136140

@@ -146,6 +150,10 @@ public function save($closure)
146150
// delete csrf session token
147151
CsrfToken::unsetToken();
148152

153+
// Send only if not in Laravel environment to avoid double sending
154+
if (!class_exists('Illuminate\Foundation\Application')) {
155+
$response->send();
156+
}
149157
return $response;
150158
}
151159

tests/server.php

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,7 @@
1616
"enum:terms" => 'Accept terms and condition',
1717
])->validate(function($response){
1818

19-
// return $response->json(1, $response->message);
20-
21-
var_dump(
22-
$response,
23-
'sss'
24-
);
25-
exit();
19+
return $response->json(1, $response->message);
2620
})->save(function($response){
2721
// access the form data
2822
$param = $response->param;
@@ -33,9 +27,6 @@
3327
// message
3428
$response->message = "Submitted Successfully";
3529

36-
dump(
37-
// $param->message,
38-
$param->toArray(),
39-
);
30+
return $response->json(200, $response->message);
4031
});
4132

0 commit comments

Comments
 (0)