2017-06-20 46 views
1

RouteCollection.php我得到MethodNotAllowedHttpException在RouteCollection.php

得到錯誤信息MethodNotAllowedHttpException這裏是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\[email protected]'); 
Route::post('backend/client/updateservice','Backend\[email protected]'); 

這裏是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

嘗試改變方法名getEditservice和postUpdateservice和路線也。 – rahulsm

+0

請檢查表單已提交的完整錯誤,然後檢查路由中該URL的方法。 –

回答

0

可以使用to,而不是url

<form ACTION="{{ URL::to('backend/client/updateservice') }}" METHOD="POST" id="form1" name="form1" > 

或者

Route::post('backend/client/updateservice',array('uses'=>'Backend\[email protected]','as'=>'updataService')); 

使用route()輔助函數爲:

<form ACTION="{{ URL::route('updataService') }}" METHOD="POST" id="form1" name="form1" > 
+0

你確定這會工作嗎? 100%? – rahulsm

+0

你試過了嗎?我的意思是你還確定嗎? – rahulsm

+0

第二個更好,你可以爲你的路線定義一個名字 –

0

問題是updateservice方法你redirect選項。更改updateservice方法本

public function updateservice() 
{ 
    $clientUpdate = Input::all(); 
    $client = Client::where('ClientID','1') -> get() -> first(); 
    $client ->update($clientUpdate); 
    return redirect('backend/client/editservice'); 
} 

因爲當它重定向它找不到重定向路徑

+0

不,它不是,它不會進入方法體內,只有當它沒有找到任何方法時纔會發生異常 – rahulsm

相關問題