4

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 Answer 1

11

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');
Sign up to request clarification or add additional context in comments.

Comments

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.