Skip to content

Conversation

@jasonvarga
Copy link
Member

This PR adds a toValuesCollection macro onto the Collection class.

Now you can do $collection->toValuesCollection() and it will convert it to a ValuesCollection filled with Values instances.

This is intended to be glue between the Blade wrapper introduced in #5201 and the query builder stuff in #5285.

Now you can perform a query in your Blade template, and convert it to a ValuesCollection so it's nice to loop over.

@foreach (Statamic::query('entries')->get()->toValuesCollection() as $entry)
  {{ $entry->title }}
  {{ $entry->toggle_field }}
@endforeach

@jasonvarga jasonvarga merged commit 8296cf7 into master Feb 15, 2022
@jasonvarga jasonvarga deleted the feature/tovaluescollection branch February 15, 2022 15:15
jasonvarga added a commit that referenced this pull request Feb 17, 2022
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