The except methods passed in options not getting excluded from route registrar.
Create something like this in routes/api.php :
Route::apiResource('todo', 'TodoController', ['except' => ['index', 'show']]);
And voila!
apiResource already utilizes the 'only' option internally with [index, show, store, update, destroy]. If you need to customize it further, just use resource. The only thing apiResource provides is dropping 'edit' and 'create'. So just use 'resource' and customize as you need.
@devcircus Yeah, I know. But, apiResource has except options, that it should work, but It doesn't. So It means that's an issue.
It's been discussed here before. That's not how it was intended to work. Submit a PR if you have a way to make it better.
@devcircus Woah, interesting. I don't find the same discussion on this repo issue tracker with keyword apiResource, so I thought there is no discussion before. Ok, I'll submit a PR.
My apologies. It must've been on one of the forums where it was discussed. My point was that this was designed to simply be a shortcut for Route::resource except 'edit' and 'create'. It gives you nothing else. So if you don't need all api actions, you simply use Route::resource with all the exceptions you need. I guess if you can roll it altogether in a elegant PR, then go for it.
@devcircus Ah, that's it. No problem, I'm just clarifying if I've checked the issue tracker and no one discussed it.
Closing since PR proposal was rejected for the moment.
Well, since "only" works with apiResource... there is a consistency problem.
If you want to be strict with ApiResource, don't make "only" work with it.
Most helpful comment
Well, since "only" works with apiResource... there is a consistency problem.
If you want to be strict with ApiResource, don't make "only" work with it.