Skip to content

Documents EntryRepository#findByIds() for PR #11668 #1657

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions content/collections/repositories/entry-repository.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ use Statamic\Facades\Entry;
| `all()` | Get all Entries |
| `find($id)` | Get Entry by `id` |
| `findByUri($uri, $site)` | Get Entry by `uri`, optionally in a site |
| `findByIds([$ids])` | Get Entries by `id`. Returns in same order as `$ids`. |
| `findOrFail($id)` | Get Entry by `id`. Throws an `EntryNotFoundException` when the entry cannot be found. |
| `query()` | Query Builder |
| `whereCollection($handle)` | Get all Entries in a `Collection` |
Expand Down Expand Up @@ -61,6 +62,14 @@ Entry::findByUri('/blog/my-first-post');
**What is the difference between `URI` and `URL`?** `URL` includes the site root (e.g. `/fr/` in a multisite), if there is one, while `URI` is site agnostic and will not. As you may have surmised, when you only have a single site — they are identical.
:::

#### Get multiple entires in a specific order by id

You may want to find some entries and have them returned in a specific order. Whilst you can use the query builder to do this, it is much more simple with the repository’s `findByIds()` method:

```php
Entry::findByIds([ 3, 1, 2 ]);
```

#### Get all entries in a collection

```php
Expand Down