2015-01-16 1 views
0

내 ApiController을 가지고 생성자에서프랙탈 setRequestedScopes 정의되지 않은 메서드

$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); 
} 

내가

http://myrestapi.dev/places/3?embed=checkins

을 테스트하려고

나는 다음과 같은 오류를 정의되지 않은 메서드 리그 \ 프랙탈 \ 관리자

전화 : setRequestedScopes()를 얻을

+0

퍼가기가 포함에 이름이 바뀐 작동합니다. 그래서 임베디드 대신에 include를 사용해야합니다. http://fractal.thephpleague.com/transformers/ 이름을 바꿀 때 코드가 정상적으로 작동한다고 생각합니다. – xAoc

답변

0

내가

을 포함

의 이름을 변경 확인

을 포함하고 내 ApiController에 다음 줄

대신 setRequestedScopes의
if (isset($_GET['include'])) { 
    $fractal->parseIncludes($_GET['include']); 
} 

을() SE 및 모든 분명