게시물 리소스 및 댓글 중첩 리소스가있는 간단한 블로그가 있습니다. 지금까지 게시물에 속한 모든 댓글을보고 게시물에 대한 새 댓글을 만들 수 있습니다.Laravel4 : 댓글 삭제
특정 의견을 삭제할 수있는 가능성을 부여하고 싶지만 어쨌든 몇 가지 실수를 저지르고 있습니다. ^/매개 변수 "의견"[ "와 일치해야합니다 경로"posts.comments.destroy "에 대한 :
@extends('master')
@section('blog')
@foreach($comments as $comment)
<div class="span11 well">
<ul>
<li><strong>Body: </strong> {{ $comment->body }} </li>
<li><strong>Author: </strong> {{ $comment->author }}</li>
</ul>
{{ Form::open(array('method' => 'DELETE', 'route' => array('posts.comments.destroy', $post_id), $comment->id)) }}
{{ Form::submit('Delete', array('class' => 'btn btn-danger')) }}
{{ Form::close() }}
</div>
@endforeach
{{ link_to_route('posts.index', 'Back to Post index') }}
이 내가 인덱스를 실행 얻을 오류는 다음과 같습니다
이
모든 의견보기comments.index
이다 ] ++ "(" "주어진 URL을 생성한다.
이것은 CommentsController 내부의 색인 방법 :
public function index($post_id)
{
$comments = Post::find($post_id)->comments;
return View::make('comments.index', compact('comments'))->with('post_id', $post_id);
}
그리고 이것이다 CommentsController 내부의 파괴 방법 : 내가 실수를하고 어디
public function destroy($post_id, $comment_id)
{
$comment = $this->comment->find($comment_id)->delete();
return Redirect::route('posts.comments.index', $post_id);
}
누군가가 제발 알 수 있습니까?
이
경로 : 당신은 당신의 경로에 정규 표현식 테스터를 뒀다Route::resource('posts', 'PostsController');
Route::resource('posts.comments', 'CommentsController');
죄송가 알렉스, 수정해야 할 코드 줄을 정확히 쓸 수 있습니까? – johnnyfittizio