Solution:
Error in the route you've identified. Its get
and must change to post
change this
Route::get('/login', ['as' => 'login', 'uses' => 'LoginController@getLogin']);
To this
Route::post('/login', ['as' => 'login', 'uses' => 'LoginController@getLogin']);
action="{{ route('login') }}" # form Submit action
Route::post('/', 'PostController@index');
Route::post('/posts/create', 'PostController@create');
Route::post('/posts', 'PostController@store');
Post or get.in case you pass post value than use post
.
View: create.blade.php
@extends('layouts.main')
@section('content')
<h1>Create new account</h1>
{{ Form::open(['route' => 'account-create-post']) }}
<div>
{{ Form::label('email', 'Email:') }}
{{ Form::email('email') }}
@if($errors->has('email')){{$errors->first('email')}}@endif
</div>
<div>
{{ Form::label('username', 'Username:') }}
{{ Form::text('username') }}
@if($errors->has('username')){{$errors->first('username')}}@endif
</div>
<div>
{{ Form::label('password', 'Password:') }}
{{ Form::password('password') }}
@if($errors->has('password')){{$errors->first('password')}}@endif
</div>
<div>
{{ Form::label('password_confirm', 'Confirm password:') }}
{{ Form::password('password_confirm') }}
@if($errors->has('password_confirm')){{$errors->first('password_confirm')}}@endif
</div>
<div>{{ Form::submit('Create account') }}</div>
{{ Form::close() }}
@stop
Controller: AccountController.php
<?php
class AccountController extends BaseController {
public function getCreate(){
return View::make('account.create');
}
public function postCreate(){
return 'Hello.';
}
}
Routes.php
<?php
Route::get('/', array(
'as' => 'home',
'uses' => 'HomeController@home'
));
/*
/Unauthenticated group
*/
Route::group(array('before' => 'guest'), function(){
/*
/ CSRF group
*/
Route::group(array('before' => 'csrf'), function(){
/*
/ Create account (POST)
*/
Route::get('/account/create', array(
'as' => 'account-create-post',
'uses' => 'AccountController@postCreate'
));
});
/*
/ Create account (GET)
*/
Route::get('/account/create', array(
'as' => 'account-create',
'uses' => 'AccountController@getCreate'
));
});