Why does Laravel's Response::json return blank if called from another function?
laravel, php
Solution
As cecilozaur commented, perhaps you need to:
return $this->respond($data);
So that the response actually gets returned to the parent function.
Problem
I'm building an API using Laravel. I'd like to pass data to a function in the base controller and have the JSON served out via Response::json() from there (the reason for this is so that the response method carries out benchmarking and logging, among other things) This works: ``` <?php public function show($id) { $data = Member::find($id); return Response::json($data); } ``` This doesn't: ``` <?php public function show($id) { $data = Member::find($id); $this->respond($data); } private function respond($data) { return Response::json($data); } ``` Can anyone tell me why Response:json() doesn't like being popped into another function? If I `echo Response::json($data)` instead of `return` it outputs the full response, including the headers. All input appreciated. Thanks.