, 나는 다음과 같이 편안 자원 세트를 만들려 : Laravel 4 : 중첩 된 리소스에 대해 올바른 중첩 컨트롤러를 작성하는 방법? Laravel 4에서
http://localhost/posts/1/comments
http://localhost/posts/1/comments/1
http://localhost/posts/1/comments/1/edit
은 ...
그래서 나는 두 개의 컨트롤러 생성 : (같은 층) 가 PostsController 및 CommentsController을, 그리고 경로는 다음과 같이 기록됩니다 posts.comments.create 0 : 나는 또한 경로를 참조 /views/comments/index.blade.php에 링크를 생성
Route::resource('posts', 'PostsController');
Route::resource('posts.comments', 'CommentsController');
을 일부 필수 매개 변수가 누락 ("게시물")에 대한 URL을 생성 : 나는 http://localhost/posts/1/comments
방문 할 때
이 페이지가 표시, MissingMandatoryParametersException를 던졌습니다 :
{{ link_to_route('posts.comments.create', 'Add new comment') }}
여기에 내가 만난 문제입니다 "posts.comments.create"를 라우팅하십시오.
어떻게 해결할 수 있습니까? 솔루션이 CommentsController의 작성 및 편집 방법에도 적용되는지 여부를 어떻게 알 수 있습니까?
public function index()
{
$tasks = $this->comment->all();
return View::make('comments.index', compact('comments'));
}
public function create()
{
return View::make('comments.create');
}
public function show($post_id,$comment_id)
{
$comment = $this->comment->findOrFail($comment_id);
return View::make('comments.show', compact('comment'));
}
감사합니다. redirect :: route를 작성할 때 또 다른 문제가 있습니다 :'redirect :: route ('posts.comments.create') -> ('post_id', $ post_id) -> withInput() -> withErrors ($ validation) -> ('message', '유효성 검사 오류가 있습니다.')'여전히 동일한 예외가 발생합니다. – JackpotK