Laravel - 路由错误

时间:2016-05-10 14:37:06

标签: laravel-5 routing

我是Laravel(5.2)的初学者,所以如果这是显而易见的,我就会道歉。我在Post控制器中有一个条目来删除传递的条目:

public function getDeletePost( $post_id )
    {

            $post = Post::where('id', $post_id)->first();
            $post->delete();
            $message = "successfully deleted";
            return redirect()->route('dashboard')->with( ['message'=> $message] );
    }

从路径文件中的函数调用:

Route::get('/delete-post/{post_id}',
            [ 'uses'=> 'PostController@getDeletePost',
             'as' => 'post.delete' ]);

从页面调用路线:

<a href="{{   route('post.delete',['post_id' => $post->id] )  }}">delete</a>

该页面显示正确的网址(http://localhost:8000/post-delete/5),但我收到以下错误,似乎无法绕过它:

Sorry, the page you are looking for could not be found.
1/1 NotFoundHttpException in RouteCollection.php line 161:

in RouteCollection.php line 161
at RouteCollection->match(object(Request)) in Router.php line 823
at Router->findRoute(object(Request)) in Router.php line 691
at Router->dispatchToRoute(object(Request)) in Router.php line 675
at Router->dispatch(object(Request)) in Kernel.php line 246
at Kernel->Illuminate\Foundation\Http\{closure}(object(Request))
at call_user_func(object(Closure), object(Request)) in Pipeline.php line 52
at Pipeline->Illuminate\Routing\{closure}(object(Request)) in CheckForMaintenanceMode.php line 44
at CheckForMaintenanceMode->handle(object(Request), object(Closure))
at call_user_func_array(array(object(CheckForMaintenanceMode), 'handle'), array(object(Request), object(Closure))) in Pipeline.php line 136
at Pipeline->Illuminate\Pipeline\{closure}(object(Request))
at call_user_func(object(Closure), object(Request)) in Pipeline.php line 32
at Pipeline->Illuminate\Routing\{closure}(object(Request))
at call_user_func(object(Closure), object(Request)) in Pipeline.php line 103
at Pipeline->then(object(Closure)) in Kernel.php line 132
at Kernel->sendRequestThroughRouter(object(Request)) in Kernel.php line 99
at Kernel->handle(object(Request)) in index.php line 54
at require_once('D:\websites\__laravel\socialnetwork\public\index.php') in server.php line 21

1 个答案:

答案 0 :(得分:0)

是的错字!我很谦卑!