1 year ago

Large list of collection items (names) - is there a way to skip to a letter?

Posted 1 year ago by nexxai

We have a large database of names, and we'd like to allow our users to jump to a particular letter in a view. We currently just use basic pagination but that's becoming untenable as the list of names is constantly growing, and by a lot.

Is there a way where we can keep pagination (if not, that's OK), but have the ability for our users to skip to a particular letter in the list?

Current lookup code:

    $people = Person::where('approved', 1)

Current (simplified) display code:

@foreach ($people as $person)

    <tr><td>{{ $person->name }}</td></tr>



I think I could probably do a groupBy, but the unintended side effect of using a groupBy is that it would either be one gigantic page split up into letter-specific names, or having a single page for each letter which will still look unbalanced if you have letters with a ton of names vs. letters with few or no names.


Please sign in or create an account to participate in this conversation.