Reputation: 9
I use Form Requests to incapsulate validation logic into files then to use it like:
public function register(RegisterRequest $request) {}
When validation is false it redirects to the index page.
How to return json with http code instead redirection?
Upvotes: 0
Views: 212
Reputation: 81
use following code :
return \response($data, $statusCode);
for example :
return \response(['name'=>'Amin'], 200);
Upvotes: 1
Reputation: 2875
From postman, you have to pass Accept
as application/json
on header tab
Upvotes: 1