Is there some way to return JSON from laravel by using something similar to abort() function.
From controller returning JSON is easy we can just call
return response()->json(['message' => 'my mesage'], 200);
But from some other place (custom class for example) to return JSON I have to create a return chain to the contoller.
Is there a way to return json without resorting to a return chain. Like using abort() function. I would like to use something similar to abort(400, 'my message') but insted of returning html like abort does return JSON.
or is there a way to overwrite abort to return JSON.
I would be thankfull solution that works for laravel 5.3 and up.
from Newest questions tagged laravel-5 - Stack Overflow http://ift.tt/2wDWeVQ
via IFTTT
Aucun commentaire:
Enregistrer un commentaire