B
B
Blud732014-01-14 14:43:51
Laravel
Blud73, 2014-01-14 14:43:51

Laravel. Creating a form with CSRF?

Help me please. I am registering. Created a UserController controller which has functions for resource index, create, update, store.
To register users, I decided to use the store.
Created a page with a form:

<?php echo "\n"; echo Form::open(array('url' => 'user')); echo Form::token(); echo "\n";  ?>
            .....

                 <?php echo Form::close(); echo "\n";   ?>
Next, I created a Route:
//Route::resource('user', 'UserController', array('only' => array('index','show','update')));
Route::post('user/store', array('before' => 'csrf'), function () {});

I think it's a bug in Routes. How to spell them correctly?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexey, 2014-01-14
@Blud73

Route::group(array('before' => 'csrf'), function()
{
      Route::resource('user', 'UserController', array('only' => array('index','show','update')));
}

or
Route::filter('csrf', function($route, $request){
});

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question