Laravel中找不到页面

时间:2016-10-23 17:21:00

标签: php html laravel-5.2

我的Route文件中的代码如下所示:

Route::delete('/subtask1/delete/{{subtask}}', 'TaskController@subtaskdestroy');
    Route::get('/home', 'HomeController@index');
    Route::get('/redirect/{provider}', 'SocialAuthController@redirect');
    Route::get('/callback/{provider}', 'SocialAuthController@callback');
});

视图文件中的代码:

<form action="/subtask1/delete/public function subtaskdestroy(Request $request, Subtask $subtask)
{
    $this->authorize('checkTaskOwner', $subtask);

    $subtask->delete();

    return redirect('/tasks');
}
" method="POST" style="display: inline-block;">
    {{ csrf_field() }}
    {{ method_field('DELETE') }}
    <button type="submit" id="delete-task-{{$subtask->id }}" class="btn btn-danger btn-xs">
    <i class="fa fa-btn fa-trash"></i>Delete
    </button>
</form>

控制器上的代码:

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

使用此代码,我收到如下错误:

{{1}}

2 个答案:

答案 0 :(得分:1)

您在定义删除路线时会出错。它应该是这样的:

X [ 0.  1.] (2,)
Y [ 2.  3.] (2,)
X [ 0.  1.] (2,)
Y [ 4.  5.] (2,)
X [ 0.  1.] (2,)
Y [ 6.  7.] (2,)
X [ 0.  1.] (2,)
Y [ 8.  9.] (2,)
X [ 2.  3.] (2,)
Y [ 4.  5.] (2,)
X [ 2.  3.] (2,)
Y [ 6.  7.] (2,)
X [ 2.  3.] (2,)
Y [ 8.  9.] (2,)
X [ 4.  5.] (2,)
Y [ 6.  7.] (2,)
X [ 4.  5.] (2,)
Y [ 8.  9.] (2,)
X [ 6.  7.] (2,)
Y [ 8.  9.] (2,)
X [ 0.  1.] (2,)
Y [ 0.  1.] (2,)
X [ 2.  3.] (2,)
Y [ 2.  3.] (2,)
X [ 4.  5.] (2,)
Y [ 4.  5.] (2,)
X [ 6.  7.] (2,)
Y [ 6.  7.] (2,)
X [ 8.  9.] (2,)
Y [ 8.  9.] (2,)

但你给了:

predict

有关路线参数的更多信息:

Laravel Route Parameters

答案 1 :(得分:0)

您在控制器中使用了return redirect('/tasks');。使用此行,页面将在成功删除数据后重定向到路由/tasks。确保您的路线文件中有/tasks路线。例如:

 Route::get('/tasks','YourController@method');