2017-03-06 105 views
0

每一個崗位列表中有Edit鏈接Laravel編輯鏈接不起作用

<a href="{{ URL::to('dashboard/post/' . $post->id . '/edit') }}" class="btn btn-default btn-edit-post">Edit</a> 

航線PostsController

public function edit($id) 
    { 
     $post = Post::findOrFail($id); 
     return view('dashboard.edit', compact('post')); 
    } 

    public function update($id, PostRequest $request) 
    { 
     $post = Post::findOrFail($id); 
     $post->update($request->all()); 
     return redirect ('dashboard'); 
    } 

但碰杯編輯按鈕

Route::get('dashboard/posts/{id}/edit', '[email protected]'); 
Route::put('dashboard/posts/{id}', '[email protected]'); 

方法我收到一個錯誤

NotFoundHttpException在RouteCollection.php線161:

有什麼不對?如何解決它?

回答

1

在你寫的帖子路由文件,並在href後

{{網址::以( '儀表盤/後 /'。$後> ID。 '/編輯')}}

Route :: get('dashboard/posts/{id}/edit','PostsController @ edit');

+0

哎喲!非常感謝! – Heidel