Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

I wish there was an *except* method #185

Open
nanadjei opened this issue Aug 24, 2022 · 1 comment
Open

I wish there was an *except* method #185

nanadjei opened this issue Aug 24, 2022 · 1 comment

Comments

@nanadjei
Copy link

The way "only" is available I wish there was an "except" or "exclude" method as well. That can be handy if you have a large amount of data to return and you can't want to go through the pain of adding all those data just to exclude only one data. Like so;

 return responder()->success(User::all())->only('id', 'name', 'height', 'dob', 'hair_color', 'gender', 'contact', 'email', 'residential_address', 'country_of_residence')->respond();

Then you can;

 return responder()->success(User::all())->exclude('create_at', 'updated_at')->respond();
@ezef
Copy link

ezef commented Sep 9, 2024

You can use a Transformer for that, it will not exclude automatically anything, but it will be clearer in the code

 return responder()
 ->success(User::all(), UserTransformer::class)
->respond();

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

No branches or pull requests

2 participants