我有我的ApiController及其构造函数
$this->fractal = $fractal;
// Are we going to try and include embedded data?
$this->fractal->setRequestedScopes(explode(',', Input::get('embed')));
变压器
class PlaceTransformer extends TransformerAbstract
{
protected $availableEmbeds = [
'checkins'
];
public function transform(Place $place)
{
return [
...
];
}
public function embedCheckins(Place $place)
{
$checkins = $place->checkins;
return $this->collection($checkins, new CheckinTransformer);
}
当我尝试测试时
我收到以下错误
调用未定义的方法League \ Fractal \ Manager :: setRequestedScopes()
答案 0 :(得分:0)
好的,我重命名了
嵌入
in
包括
并在我的ApiController中查看以下行
if (isset($_GET['include'])) {
$fractal->parseIncludes($_GET['include']);
}
而不是setRequestedScopes(),所有工作都清晰