Resourceful controllers: overriding route names and parameters
Resource controllers are amazing tool to work with CRUD functions in Laravel. But what if their default functionality isn't 100% suitable and you want to override some defaults? Let's see what you can do.
Overriding route names
Default functionality in routes:
It will assume that controller will have these methods:
And the same will apply to route names - they will be assigned as photo.create, photo.show etc. So what if you want to override them? There's a parameter for that.
I know that this overriding is probably quite an edge-case, but it was news for me, so decided to share.
This is one of the places in documentation which people don't get to, until they need to solve that actual problem. And then they usually go to forums for the answer. Hopefully now they will google and land on this article.
Link to the official documentation.