Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

christogonus's avatar

Livewire Pagination Returns Error When I return to page 1

I have made a Livewire component to show a list of codes, paginate in sets of 20.

The first time I load the page, everything works fine, I can go from page1 - page 5 But when I go from other pages back to Page 1, it throws error as seen here

ErrorException Undefined offset: 7 (View: C:\xampp\htdocs\clients\dashboard\resources\views\livewire\promo-code\dashboard.blade.php) http://lara-dashboard.test/admin/settings/promo-codes?page=2

The Error Shown https://prnt.sc/1pwbkyj

Here is the Livewire Class:

`` use Livewire\Component; use Livewire\WithPagination; use App\Models\PromoCode; use App\Models\Role;

class Dashboard extends Component { use WithPagination;

protected $paginationTheme = 'bootstrap';

public function render()
{
    $roles = Role::all();

    return view('livewire.promo-code.dashboard', [
        'roles' => $roles,
        'codes' => PromoCode::paginate(10),
    ]);
}

} ``

The Livewire Class https://prnt.sc/1pwfix9

GIF of demonstration https://gifyu.com/image/yPPY

0 likes
3 replies
tykus's avatar

What does the dashboard.blade.php view template look like?

1 like

Please or to participate in this conversation.