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

[10.x] Add "dot" method to Illuminate\Support\Collection class #46265

Merged
merged 2 commits into from
Feb 24, 2023

Conversation

medeirosinacio
Copy link
Contributor

This PR adds the dot method to the Illuminate\Support\Collection class in Laravel.

Additionally, I recently had a need to perform the dot operation on an array, extract 5 items from the flattened result, and then convert it back to a multi-dimensional array using the undot method. Unfortunately, achieving this with the current implementation required me to write the following code:

Arr::undot(array_slice(Arr::dot($keys), 0, 5))

With this PR, users can now easily achieve the same result using the following code:

collect($keys)->dot()->take(5)->undot()

This simplifies the code and makes it more readable, providing a better developer experience for users of Laravel's Illuminate\Support\Collection class.

@BafS
Copy link
Contributor

BafS commented Aug 19, 2024

Me thinking dot would do a dot product, the name is confusing.

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

Successfully merging this pull request may close these issues.

3 participants