I'm trying to make a simple post through a form, the route exists and the token is there, but when a submit is made always returns '404 Not Found'.
Route:
Route::group(['middleware' => ['web']], function () {
Route::post('/cadastro', 'UsuarioPost@cadastro');
});
UsuarioPost Controller:
class UsuarioPost extends Controller
{
public function cadastro(Request $request)
{
return dd($_POST);
}
}
View with the form:
<form id="f_cadastro" method="POST" action="{{ URL::to('/cadastro') }}">
{{ csrf_field() }}
<button type="submit">Cadastrar</button>
</form>
Is there something new from laravel 5.1 to 5.2 in form submiting? This used to work fine in the previus version, even without the group in the route.
So, finally working.
The deal was with apache, and not laravel. Apaches httpd.conf file (apaches directory/conf/httpd.conf) had AllowOverride disabled as default, wich is needed by laravel. So I had to change every single "AllowOverride none" for "AllowOverride all", and removed the line "Require all denied".
Having my apache DocumentRoot already set to the public folder from my project everthing worked fine.
I suggest you to use named routes instead of this strategy, is more convenient.
Route::get('/profile', [
'as' => 'profile.index',
'uses' => 'ProfileController@index',
]);
And then you can generate the url from your views or codes using only
{{ route('profile.index') }}