Closed
Description
Hi,
I could be wrong but it seems that collections responses are not transformed by my Transformer. It do work for single Model returns :
Here is my code
API::transform('User', 'UserTransformer');
Route::api(['version' => 'v1','prefix'=>'api', 'protected' => true], function()
{
Route::get('me', function(){
return API::user();
});
Route::get('users', function()
{
return User::all();
});
Route::resource('room-types', 'Admin\Controllers\Api\RoomTypesController');
});
returns for /api/me is correct (name parameter is correct) :
{
"data": {
"id": 3,
"name": "Julien Moreau",
"email": "admin@example.com",
"activated": true
}
}
meanwhile return for /api/users is not correct
{
"users": [
{
"id": 1,
"email": "admin@admin.com",
"last_login": "2014-04-30 14:28:03",
"first_name": "Admin",
"last_name": null,
"updated_at": "2014-04-30 14:28:03"
},
{
"id": 2,
"email": "user@user.com",
"last_login": null,
"first_name": null,
"last_name": null,
"updated_at": "2014-04-30 14:24:00"
},
{
"id": 3,
"email": "admin@example.com",
"last_login": "2014-05-01 08:02:54",
"first_name": "Julien",
"last_name": "Moreau",
"updated_at": "2014-05-01 08:02:54"
}
]
}
The "testTransformingCollectionUsingTransformerClassName" test from "TransformerTest.php" seems to ensure that it works.
Other question, why is the key param for single models "data" and not "user" as it should be?
Metadata
Metadata
Assignees
Labels
No labels