저는 데이터베이스 추상화 및 테스트 목적으로 작동하는 저장소 패턴을 얻으려고했습니다. 나는 반나절 동안 노력하고있어. 오류가없는 빈 화면 (내용이 전혀 전송되지 않음) 만 있습니다. 이 저장소 패턴을 사용하여 것으로 보인다 :Laravel 저장소 오류 없음, 빈 페이지
- Laravel 4.1에서 작동하지 않습니다
- 난 그냥되는거야 PHP 5.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');
}
}
정확히 어떤 URL을 실행 했습니까? 컨트롤러의 어느 부분이 시작되고 있습니까? –
/대시 보드/대시 보드 - json. __construct를 꺼내면 반환 내용이나 표시 및 오류와 같이 작동합니다. –
'Survey' 모델의 코드도 여기에 두어야한다고 생각합니다.이 모델의'all' 함수는 무엇을합니까? 아무것도 돌려주지 않니? –