2017-03-18 60 views
0

嘗試提交表單時,我得到MethodNotAllowedException。這裏是我的路線不允許使用Laravel方法

Route::group(['middleware' => 'auth', 'prefix' => 'admin'], function() { 

    Route::resource('user', 'UserController'); 
    Route::get('user/destroyMe/{destroyMe}', ['as' => 'user.destroyMe', 'uses' => '[email protected]']); 
    Route::get('user/changeState/{id}', ['as' => 'user.changeState', 'uses' => '[email protected]']); 
}); 

,這裏是形式與部分存儲新用戶:

​​

我內route:list檢查,我很清楚有user.store命名路線和方法的航線是POST。我無法弄清楚爲什麼我會得到異常?

編輯

我確實有Laravel的AdminLTE安裝Link,但我重寫它的路由。針說,其他每條路線的作品。

EDIT 2

我試圖使一個手動路線:

Route::post('admin/user', '[email protected]'); 

,並張貼到url('admin/user')但還是一樣的結果呢?

編輯3

清除緩存也沒幫助。

EDIT 4

經過進一步檢查,打一個不存在的隨機路由時,我得到一個錯誤報頭Sorry, the page you are looking for could not be found.,但如果我做任何的POST路線,我得到Whoops, looks like something went wrong.(包括儘管如此,錯誤也會觸發相同的異常)

Laravel日誌爲空

+0

哪個路線user.store路線我看不到? – Araz

+0

並且我也看不到路線中的Route :: post? – Araz

+0

'Route:resource'正在製作所有默認路由 – Norgul

回答

1

我發現了錯誤causi所有的麻煩。在我的形式有一個線

<input name="_method" value="PUT" type="hidden"> 

它潛入有通過複製/粘貼我edit代碼

0

試試這樣說:

{!! Form::open([ 'route' => 'user.store', 'method' => 'POST', 'files' => 'true' ]) !!} 

,並做其關閉。

 // 
{{ Form::close() }} 

編輯: 如何做這種方式:

routes.php

Route::any('admin/user', '[email protected]'); 

而在controller

public function form(){ 
    print_r(Input::get()); die; #Hope that you are using Input. 
} 
+0

這是使用包編寫它的另一種方法。同樣的結果很不幸 – Norgul

+0

@Norgul用一種新方法編輯這個。 –

+0

這是輸出Array [[_token] => GS8E6Jx9Xrs2B97qa8VmRquuCdTc259aecdrJdrd [name] => Tyler Clay [email] => [email protected] [role_id] => 7 [equipment] => Array([0] => 2 [1] => 3 [2] => 4)[supervisor] => Array([0] => 2 [1] => 4)[_method] => PUT [save] =>保存)它正在擊中路由 – Norgul