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

[11.x] Add multiply to collection #51870

Merged
merged 3 commits into from
Jun 21, 2024

Conversation

patrickomeara
Copy link
Contributor

When I'm building UIs I usually want to know what the layout will look like if there is a lot of things. I am constantly doing something like this for strings:

<div>
  {{ $user->name }} 
  {{ $user->name }} 
  {{ $user->name }} 
  {{ $user->name }}
</div>

But when it comes to collections things get a little more difficult.

@foreach($class->students as $student)
   <x-student :student="$student" />
@endforeach

I've had this method in a macro for quite some time and thought it might be useful for others.

@foreach($class->students->multiply(4) as $student)
   <x-student :student="$student" />
@endforeach

Multiply the items in the collection by the multiplier.
@driesvints driesvints changed the title Add multiply to collection [11.x] Add multiply to collection Jun 21, 2024
@taylorotwell taylorotwell merged commit 33424be into laravel:11.x Jun 21, 2024
28 checks passed
@patrickomeara patrickomeara deleted the collection-multiply branch June 21, 2024 15:54
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