vandan's avatar
Level 13

Custom Function In Resource Route ?

Hii Guys i have questions about resource

i dont know can i use custom function made in resource route or inbuilt function i used. or is it possible to create custom function in resource route? any idea or other method to solved this ?

Thanks

0 likes
3 replies
tisuchi's avatar

@van-india

If you want to create a different route in the resource, you can do that easily.

Here, what's you need to do-

Route::get('foo/bar', 'FooController@bar');
Route::resource('foo', 'FooController');
Amaury's avatar

"Remember to keep your controllers focused. If you find yourself routinely needing methods outside of the typical set of resource actions, consider splitting your controller into two, smaller controllers."

Quotes from Laravel docs

You can extract the logic you need to implement to an other dedicated restful controller or even a single invokable controller class.

Please or to participate in this conversation.