6

Been building a framework website using Laravel and working on the user system.

I am using the controller by a resource route:

Route::resource('user', 'UserController');

Which works fine for all the normal create, index, store etc function in the controller.

For my registration form this is the opening:

{{ Form::open(array('route' => 'user.store', 'class'=>'small-form form-holder')) }}

Thinking how nice this is, I created a login function in my UserController and tried this for my login form:

{{ Form::open(array('route' => 'user.login', 'class'=>'small-form form-holder')) }}

However this returns a route not defined error. Is this because of the resource route that I set? I know I could set a custom route which uses the controllers login method but I like this way of doing things.

1 Answer 1

10

Using Resource will generate following route names by default

user.index
user.create
user.store
user.show
user.edit
user.update
user.destroy

more information RESTful Resource Controllers

If you want to create another route you could do this way

Route::get('user/login', 'UserController@login');

Route::resource('user', 'UserController');

note: you should define those routes before your call to Route::resource

for more information you can look at RESTful Resource Controllers in Adding Additional Routes To Resource Controllers session

Sign up to request clarification or add additional context in comments.

1 Comment

the note in the answer is very important. tnx

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.