-
Notifications
You must be signed in to change notification settings - Fork 11.1k
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
[10.x] Add data_remove helper #47618
[10.x] Add data_remove helper #47618
Conversation
I think you can use Collection! |
@milwad-dev can you please elaborate? The |
As per the fact that we have Just a question: following the naming convention of existing helpers, why not |
@ajmeireles as mentioned in the PR, I wasn't sure about naming the function |
@PhiloNL |
Why don't use just https://laravel.com/docs/10.x/helpers#method-array-forget |
|
Had a package similar to this from long time ago: https://github.com/cdinopol/data-guard |
|
This PR adds a new helper to the Collection helper. In addition to the existing
data_get
,data_set
, anddata_fill
, this will add thedata_remove
helper to remove keys from objects or arrays easily. This is ideal if you want to remove keys from nested objects or arrays using the wildcard helper.For example:
I wasn't sure about naming the function
data_forget
instead ofdata_remove
as both terms are used throughout the framework. Let me know if you want the name changed.Have a great day! 🙌🏻