2016-02-12 37 views
0

我想通過一個表單做一個簡單的帖子,路由存在,並且令牌存在,但是當提交時總是返回'404 Not Found'。在Laravel 5.2中的表格沒有找到路線

路線:

Route::group(['middleware' => ['web']], function() { 
    Route::post('/cadastro', '[email protected]'); 
}); 

UsuarioPost控制器:

class UsuarioPost extends Controller 
{ 
    public function cadastro(Request $request) 
    { 
     return dd($_POST); 
    } 
} 

查看與形式:

<form id="f_cadastro" method="POST" action="{{ URL::to('/cadastro') }}"> 
    {{ csrf_field() }} 
    <button type="submit">Cadastrar</button> 
</form> 

是否有形式submiting東西從laravel 5.1新的5.2? 這用於在previus版本中正常工作,即使路徑中沒有該組。

+0

你還有其他路線嗎? –

+0

使用'cadastro'而不是'/ cadastro'。另外,更改'URL ::('到'url(' – manix

+0

Eduardo Pacios,我上面有另外一條路線,'Route :: get('/','Home @ home');',這個工作正常,我嘗試把帖子放在上面,結果相同 –

回答

0

所以,最後的工作從您的視圖或代碼的URL。

這筆交易是與Apache,而不是laravel。 apaches httpd.conf文件(apaches目錄/ conf/httpd.conf)將AllowOverride作爲默認值禁用,這是laravel所必需的。所以我必須更改每個「AllowOverride none」爲「AllowOverride all」,並刪除了「Require all denied」行。

讓我的apache DocumentRoot已經從我的項目everthing設置爲公用文件夾工作正常。

0

我建議你用named routes代替這個策略,比較方便。

Route::get('/profile', [ 
    'as' => 'profile.index', 
    'uses' => '[email protected]', 
]); 

然後你就可以使用只有

{{ route('profile.index') }} 
+0

)感謝您的回覆,改變它... –

+0

是的,我確實改變了路線:: post –

+0

是的,我的只是一個例子:) – unnikked