我现在的代码出现问题,而且每当我尝试访问时,似乎找不到我指定的路径。
路线:
Route::post('nniscaseassociates/pushreliever/{id}', 'NnisCaseAssociateController@pushreliever');
Route::get('nniscaseassociates/{id}/reliever', 'NnisCaseAssociateController@reliever');
查看:
<form method="POST" action="/nniscaseassociates/pushreliever/{{ $caseassociate->nnis_case_id }}">
{{ method_field('PUT') }}
{{ csrf_field() }}
<...Fields...>
</form>
控制器:
public function reliever($id)
{
//this will be nniscase id then
$caseassociate = NnisCaseAssociate::findOrFail($id);
//return dd($caseassociate);
return view('nniscaseassociates.reliever', compact('caseassociate'));
}
public function pushreliever(Request $request, $id)
{
...Statements...
return redirect('nniscases/'.$caseassociates->nnis_case_id.'/edit');
}
答案 0 :(得分:2)
您正在发出PUT
个请求,而不是POST
。
从表单中删除此行:
{{ method_field('PUT') }}
或
将您的POST
路线更改为PUT
:
Route::put
答案 1 :(得分:-1)
您尚未在PUT method
web.php
Route::put('nniscaseassociates/pushreliever/{id}', 'NnisCaseAssociateController@pushreliever');
在您看来:
<form method="POST" action="/nniscaseassociates/pushreliever/{{ $caseassociate->nnis_case_id }}">
{{ method_field('PUT') }}
{{ csrf_field() }}
<...Fields...>
</form>
在您的控制器中:
public function pushreliever(Request $request, $id)
{
echo $id;
}
答案 2 :(得分:-2)
你应该试试这个:
<form method="POST" action="{{ url('nniscaseassociates/pushreliever',[$caseassociate->nnis_case_id]) }}">