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

Make the Collection::times callback optional #19278

Merged
merged 3 commits into from
May 19, 2017
Merged

Make the Collection::times callback optional #19278

merged 3 commits into from
May 19, 2017

Conversation

CupOfTea696
Copy link
Contributor

Follow up on #19276

Allows calls to Collection::times without the callback parameter, so you can create simple range collections and maybe modify them manually later with map or mapWithKeys methods.

Use case example:

Collection::times(2)->mapWithKeys(function ($number) {
    return ['slug-'.$number => 'Title '.$number];
})->toArray();


/**
 *   [
 *       ['slug-1' => 'Title 1'],
 *       ['slug-2' => 'Title 2']
 *   ]
 */

@taylorotwell taylorotwell merged commit 07ea288 into laravel:5.4 May 19, 2017
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.

2 participants