Skip to content

Conversation

nadinengland
Copy link

@nadinengland nadinengland commented Apr 5, 2025

This PR adds whereInId to EntryRepository. See docs PR

$items = \Statamic\Facades\Entry::whereInId([ 3, 1, 0, 2 ]);

$this->assertInstanceOf(\Statamic\Entries\EntryCollection::class, $items);
$this->assertCount(3, $items);
$this->assertEveryItemIsInstanceOf(\Statamic\Contacts\Entries\Entry::class);
$this->assertEquals([ 3, 1, 2 ], $items->map->id());

Notable functionality:

  • Entries are returned in order of their id's position in the original input argument.
  • Missing IDs are omitted from resultant collection.
  • Entries are first loaded from Blink, if cached, and remainder are loaded from the DB.

Relevancy to core

This is part of a wider piece of work I've start to add a fairly large reduction in DB queries to the statamic/eloquent-driver. The principal idea is to route as many components as possible through the repositories. As I was adding this to the package, parity with the core Repository contract felt good as well: PR on statamic/cms.


Note: original method was findByIds.

@ryanmitchell
Copy link
Contributor

ryanmitchell commented Apr 6, 2025

Thanks for the PR.

The goal of this driver is to match the functionality and contract methods provided by core. So for this to merge the core PR would be to be accepted - il leave that for the core team to decide.

@duncanmcclean
Copy link
Member

Marking this as a draft until the Core PR has been merged.

@ryanmitchell
Copy link
Contributor

@nadinengland now that the core PR has merged do you intend to update this to match?

@nadinengland nadinengland force-pushed the feature/entries-find-by-ids branch from 9f6271c to 501f528 Compare October 6, 2025 12:12
@nadinengland
Copy link
Author

Hey @ryanmitchell, yes my branch has been updated to reflect the core's method. Thanks for your patience on my delay!

@nadinengland nadinengland marked this pull request as ready for review October 6, 2025 12:15
@duncanmcclean duncanmcclean changed the title Adds EntryRespository#findByIds() Implement EntryRespository::whereInId() Oct 6, 2025
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