Use onEachSide() on paginated Eloquent queries to adjust the number of page links shown beside the current page.
Default pagination controls can show too many numeric page links on mobile viewports. Calling onEachSide(1) limits pagination controls to a clean, minimal set of links.
use App\Models\User;
// Displays 1 page link on each side of the active page
$users = User::paginate(15)->onEachSide(1);
- Controls how many numeric page buttons display beside active page number
- Prevents pagination controls from overflowing narrow mobile viewports
- Works out of the box with default Blade pagination templates
Related Tips
View all tips →Transform Paginated Records Without Breaking Links Using through()
Use the through() method on paginators to transform item collections without losing pagination metadata and link generators.
Refresh and Pessimistically Lock Models with refreshForUpdate() in Laravel 13.27
Laravel 13.27 adds refreshForUpdate(), reloading an existing model instance in-place with fresh database attributes while acquiring an exclusive FOR UPDATE row lock.