我在MethodNotAllowedHttpException
RouteCollection.php
这里是service.blade.php
<form ACTION="{{ url('backend/client/updateservice' ) }}" METHOD="POST" id="form1" name="form1" >
<input type="hidden" name="_token" value="{{ csrf_token() }}">
</form>
这里是route.php
Route::get('backend/client/editservice','Backend\ClientController@editservice');
Route::post('backend/client/updateservice','Backend\ClientController@updateservice');
这是ClientController.php
public function editservice()
{
$client = Client::where('ClientID','1') -> get() -> first();
return view('backend/client.service',compact('client'));
}
public function updateservice()
{
$clientUpdate = Input::all();
$client = Client::where('ClientID','1') -> get() -> first();
$client ->update($clientUpdate);
return redirect('backend/client/service');
}
答案 0 :(得分:0)
您可以使用to
代替url
<form ACTION="{{ URL::to('backend/client/updateservice') }}" METHOD="POST" id="form1" name="form1" >
或者
Route::post('backend/client/updateservice',array('uses'=>'Backend\ClientController@updateservice','as'=>'updataService'));
使用route()
辅助函数:
<form ACTION="{{ URL::route('updataService') }}" METHOD="POST" id="form1" name="form1" >
答案 1 :(得分:0)
问题出在redirect
方法的updateservice
选项中。将updateservice
方法更改为此
public function updateservice()
{
$clientUpdate = Input::all();
$client = Client::where('ClientID','1') -> get() -> first();
$client ->update($clientUpdate);
return redirect('backend/client/editservice');
}
因为重定向时无法找到重定向路径