-
Notifications
You must be signed in to change notification settings - Fork 141
Open
Description
Hello,
I have an issue with transform and availableIncludes.
This is my LeagueTransformer.php
<?php
...
/**
* List of resources possible to include
*
* @var array
*/
protected $availableIncludes = [
'teams'
];
public function transform(League $league)
{
return [
'id' => (int) $league->id,
'name' => (string) $league->name,
'slug_name' => (string) $league->slug_name,
'nice_name' => (string) $league->nice_name,
'image_logo' => (string) $league->image_logo_league,
'active_year' => (string) $league->year,
'country_code' => (string) $league->country_code
];
}
/**
* Include Teams
*
* @return League\Fractal\ItemResource
*/
public function includeTeams(League $league)
{
// here i have my problem
$teams = $league->teams();
return $this->collection($teams, new TeamsTransformer(), 'teams');
}
When i do, $leagues->teams()->count() i got, 30 rows, but this never passed out to response. And yes, i put on my query string ?include=teams, but nothing. This is the result,
{
"data": [
{
"id": 1,
"name": "Argentina - Primera Division",
"slug_name": "",
"nice_name": "Argentina - Primera Division",
"image_logo": "http://thumb.resfu.com/media/img/league_logos/primera_argentina.png?size=120x&ext=png&lossy=1&1",
"active_year": "2016",
"country_code": "AR",
"teams": {
"data": []
}
}
]
}
Metadata
Metadata
Assignees
Labels
No labels