Have you tried spelling the method name with only the first include letter in uppercase?
public function includeLikescount
I have a PhotoTransformer with some includes. For example, Likes:
class PhotoTransformer extends TransformerAbstract
{
protected $availableIncludes = [
'likes',
];
...
public function includeLikes(Photo $photo)
{
Everything works without problems. But now I want to add a new type of includes - likescount:
class PhotoTransformer extends TransformerAbstract
{
protected $availableIncludes = [
'likes',
'likescount',
];
...
public function includeLikesCount(Photo $photo)
{
But I get a response:
{
"headers": {}
}
How can I include this arbitrary data into the Fractal Transformer?
It was my mistake! I used lazy-eager loading, so when the model does not exist, it throws an exception. LOL)
Please or to participate in this conversation.