Skip to content
This repository has been archived by the owner on Jul 16, 2021. It is now read-only.

API Resources & except Option #1005

Open
MatthewSH opened this issue Feb 15, 2018 · 1 comment
Open

API Resources & except Option #1005

MatthewSH opened this issue Feb 15, 2018 · 1 comment

Comments

@MatthewSH
Copy link

I know this has been discussed on the laravel/framework before here and a PR was sent here (which I personally think was too much change when you could have just changed the return value from only to except).

I wanted to bring this up because of something @taylorotwell said on the PR:
"Just use Route::resource if you are going to limit the methods anyways."

I get that we could use just the regular Route::resource but at the same time could the apiResource function (here) just be changed from...

return $this->resource($name, $controller, array_merge([
        'only' => ['index', 'show', 'store', 'update', 'destroy'],
], $options));

to

return $this->resource($name, $controller, array_merge([
        'except' => ['create', 'edit'],
], $options));

Doing it this way will allow us to override only and except without having any overlap, unless of course you wanted create or edit in which case you should use the regular resource as that defeats the purpose. I want to use apiResource in my API routes to help keep up with the consistency of how I use it. I just don't need the update method and it seems kind of strange that I can't just pass it as an except option.

I would like to here some thoughts on this as well as any issues that could occur with this. The only "issue" I could think of is if the resource controller was updated with a new displaying method of some sort...then we would have to update the function...but that could also happen with it's current state so it doesn't matter too much either way.

@lucasmichot
Copy link

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants