@salebab I could not resist, I had to try it and it works. But how do you use serializers with this package?
I have this:
$manager = new Manager();
$manager->setSerializer(new DataArraySerializer());
$resource = new Collection($arrangements, new ArrangementTransformer());
return $manager->createData($resource)->toArray();
Is there a way I can optimize this.
Also if I use the code above I have no use for your package because this line
return $this->fractal->collection($arrangements, new ArrangementTransformer());
is of not much use to me if I want to wrap item and collection in data.
Also I am getting output for collection:
{
"data": [
{
"active": false,
"featured": false,
"order": 1,
"slug": "1412085610-quibusdam"
},
{
"active": false,
"featured": true,
"order": 2,
"slug": "1412085611-non"
}
]
}
And for single item:
{
"data": {
"active": false,
"featured": false,
"order": 1,
"slug": "1412085610-quibusdam"
}
}
But in Fractal documentation this is the correct output:
// Item
[
'data' => [
'foo' => 'bar'
],
];
// Collection
[
'data' => [
[
'foo' => 'bar'
]
],
];
Why is there a difference in brackets?
Can you please post a full example on how you do that.