2014-11-10 2 views
0

저는 데이터베이스 추상화 및 테스트 목적으로 작동하는 저장소 패턴을 얻으려고했습니다. 나는 반나절 동안 노력하고있어. 오류가없는 빈 화면 (내용이 전혀 전송되지 않음) 만 있습니다. 이 저장소 패턴을 사용하여 것으로 보인다 :Laravel 저장소 오류 없음, 빈 페이지

  1. Laravel 4.1에서 작동하지 않습니다
  2. 난 그냥되는거야 PHP 5.3에
  3. 또는 작동하지 않습니다 바보

    class EloquentSurveyRepository implements SurveyRepositoryInterface 
    { 
        protected $surveyModel; 
    
        public function __construct(Survey $survey) 
        { 
         $this->surveyModel = $survey; 
        } 
    
        public function all() 
        { 
         return $this->surveyModel->all(); 
        } 
    } 
    
    interface SurveyRepositoryInterface 
    { 
        public function all(); 
    } 
    
    class DashboardController extends BaseController 
    { 
    
        protected $surveys; 
    
        public function __construct(SurveyRepositoryInterface $survey) 
        { 
         $this->surveys = $survey; 
        } 
    
        public function getDashboardJson() 
        { 
         $surveys = $this->surveys->all(); 
         dd($surveys); 
        } 
    } 
    

    App::bind('SurveyRepositoryInterface', 'EloquentSurveyRepository');

조사 모델

class Survey extends EloquentSurveyRepository { 

protected $table = 'lime_surveys'; 
protected $primaryKey = 'sid'; 

public function surveyls() { 
    return $this->hasOne('Surveyls', 'surveyls_survey_id'); 
} 
} 
+0

정확히 어떤 URL을 실행 했습니까? 컨트롤러의 어느 부분이 시작되고 있습니까? –

+0

/대시 보드/대시 보드 - json. __construct를 꺼내면 반환 내용이나 표시 및 오류와 같이 작동합니다. –

+0

'Survey' 모델의 코드도 여기에 두어야한다고 생각합니다.이 모델의'all' 함수는 무엇을합니까? 아무것도 돌려주지 않니? –

답변

2

나는 문제가 여기 Survey 모델이라고 생각 :

편집 ... 그랜드합니다. 이제 당신은 :

class Survey extends EloquentSurveyRepository { 

이 오히려 설득력을 확장해야합니다 :

class Visit extends Eloquent { 

또한 (아마 여기에 예를 maximum nested function level reached 여기를 얻을 수있다) 더 많은 정보를 얻을 수있는 사용자 환경에 truedebug을 시도 할 수 있습니다.

+0

나는 월요일이 싫다. 나는 그것을 발견하지 못했다고 믿을 수 없다! 디버그가 이미 켜져 있기 때문에 빈 페이지가 있다는 것에 혼란스러워졌습니다. 감사! –

+0

@JamesElliott 기꺼이 도와 드리겠습니다. –