Vuk Stanković Vuk Stanković - 1 year ago 74
PHP Question

Correct way of adding additional routes to resource controller

I was wondering if there is a more elegant or in any way "correct" way of adding additional routes to resource controller?

For instance I could have

and route it with

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

And it will route methods according to Laravel docs

But if for any reason I wanted to add a method outside of this scope I could do something like

Route::get('users/token', 'UserController@authToken');

So obviously this works, but is there another way of doing this?

Answer Source

No, there is no better way to do that. Since ::controller was deprecated, you should explicitly declare each additional route.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download