Here is my CSRF as hidden
<input type="hidden" name="_token" value="<?php echo csrf_token(); ?>">
And my csrf is generated as usual
While i am passing into route for a controller
Here is my old route
Route::post('register', 'RegisterController@registeruser');
And to make it with csrf
Route::post('register', array('before' => 'csrf', function()
{
return 'You gave a valid CSRF token!';
}));
as per the Laravel Docs
While i routing it to the controller
Route::post('register', array('before' => 'csrf', RegisterController@registeruser()
{
return 'You gave a valid CSRF token!';
}));
I am getting the error
syntax error, unexpected '{', expecting ')'
What is the mistake i am doing and how can i fix this ?
Your route should be this:
Then you can handle it in your controller