I have an RESTful API with controllers that should return a JSON response when is being hit by my android application and a \"view\" when it\'s being hit by a web browser. I\'m
You can use
if ($request->wantsJson()) { // enter code heree }