Laravel response transformations not working Laravel response transformations not working json json

Laravel response transformations not working


Even though this question is over a year ago, however for the sake of anyone who would have similar issue, the suspect here is the fact that you used: item instead of collection.

If the $account contains a collection, then it means this answer is correct: that is, this:

return $this->response->item($account, new UserBankAccountTransformer::class);

Should be:

return $this->response->collection($account, new UserBankAccountTransformer::class);

PS: I also Encountered this on Laravel 5.2.* thats why I feel this might help.