Reputation: 1862
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 ?
Upvotes: 0
Views: 256
Reputation: 60058
Your route should be this:
Route::post('register', array('before' => 'csrf', 'uses' => 'RegisterController@registeruser');
Then you can handle it in your controller
class RegisterControllerextends Controller {
protected function registeruser()
{
return 'You gave a valid CSRF token!';
}
}
Upvotes: 2