3
votes

I'm using laravel 5.2 and I wanted to know if there's an option to include into the resource more methods.

for example, Id'e like to create a POST method called getUsersList which I can limit the results. I know I can just add in the routes separately from the resource a new route, but I would need to do this for every route I do.

What's the best way to do this?

1

1 Answers

11
votes

Of course you can add new actions (methods) to RESTful controllers.

Just add method and create the route for this action:

Route::post('foo/bar', 'FooController@bar');

And don't forget to put this route before RESTful route:

Route::post('foo/bar', 'FooController@bar');
Route::resource('foo', 'FooController');