Solution:
You are obtaining that error since you are posting to a GET
route.
I would interrput your routing for validate
into a separate GET
and POST
routes.
New Routes:
Route::post('validate', 'MemberController@validateCredentials');
Route::get('validate', function () {
return View::make('members/login');
});
Thereafter your controller method could only be
public function validateCredentials()
{
$email = Input::post('email');
$password = Input::post('password');
return "Email: " . $email . " and Password: " . $password;
}
My doubt is the problem lies in your route definition.
You identified the route as a GET
request however the form is possibly sending a POST
request. Alter your route definition.
Route::post('/validate', 'MemberController@validateCredentials');
It's usually better practice to use named routes (uses to scale in case the controller method/class changes).
Route::post('/validate', array(
'as' => 'validate',
'uses' => 'MemberController@validateCredentials'
));
In the form employ the following
<?php echo Form::open(array('route' => 'validate')); ?>
The issue is the you are employing POST
however really you have to perform PATCH
To solve this add
<input name="_method" type="hidden" value="PATCH">
Only after the Form::model
line
I encountered this issue as well and the other answers here were useful, however I am using a Route::resource
which takes care of GET
, POST
, and other requests.
In my instance I left my route as is:
Route::resource('file', 'FilesController');
And easily modified my form to submit to the store
function in my FilesController
{{ Form::open(array('route' => 'file.store')) }}
This solved the issue, and I thought it was worth pointing out as a separate answer whereas several other answers point out including a new POST
route. This is an option however it's not required.
That is since you are posting data through a get method.
Instead of
Route::get('/validate', 'MemberController@validateCredentials');
Attempt this
Route::post('/validate', 'MemberController@validateCredentials');