2016-06-29 2 views
0

현재 작업중인 프로젝트와의 관계를 설정하려고합니다. 내가 얻는 오류는 다음과 같습니다. MacroMagicCallException in Macroable.php 라인 81 : 메소드 조직이 존재하지 않습니다.MacroMore.php의 BadMethodCallException 81 :

여기 내 가게 방법입니다.

공공 기능 저장소는 내 CalendarEvent 모델 나의 관계는 내 조직 모델이

public function Organization() 
{ 
    return $this->belongsTo('App\Organization'); 
} 

의 관계처럼 설정 (요청 $ 요청) {

$calendar_event = new CalendarEvent(); 

$calendar_event->title   = $request->input("title"); 
$calendar_event->start   = $request->input("start"); 
$calendar_event->end    = $request->input("end"); 
$calendar_event->is_all_day  = $request->input("is_all_day"); 
$calendar_event->background_color = $request->input("background_color"); 



$request->Organization()->calendar()->save($calendar_event); 

return redirect()->route('calendar_events.index')->with('message', 'Item created successfully.'); 

}이 설정되어 이 같은

public function calendar() 
{ 
    return $this->hasMany('App\CalendarEvent'); 
} 

도와 줘서 고마워.

답변

0

경로 모델 바인딩을 설정 했습니까? 그리고 그 설정으로도 요청으로부터 모델에 액세스 할 수 있다고 생각하지 않습니다. 주입하려는 모델에 대해 적절한 매개 변수를 설정해야합니다.

public function store(Request $request, YourModel $model) { 

} 

또는 문제

$calendar_event에서 해당 작업을 수행해야 할 때이처럼, $request에 저장하려고한다는 것입니다 :

$calendar_event->Organization()->calendar()->save($calendar_event); 
관련 문제