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

Ligonsker's avatar

Server fetched partials + pagination - how to remove the partial route?

Hello,

I am calling a table with pagination using server-fetched partial.

The table is at www.example.com/mypage.

I also have a route that fetched the partial via the fetch() API on mypage-partial, which returns the table with the pagination links and inserts them inside the #table-container div:

// mypage-partial.blade.php
<table>
 // display the data
</table>
{{ $data->appends(['queryStringKey' => 'queryStringVal'])->links() }}

The problem is that the new pagination links contain the API route, so when I click the numbers of the pagination, it redirects to:

at www.example.com/mypage/mypage-partial, instead of at www.example.com/mypage

How can I prevent the server-fetched partial links from having the API route?

Thanks

0 likes
2 replies
Ligonsker's avatar
Ligonsker
OP
Best Answer
Level 8

@vincent15000 I ended up using the withPath() method which lets you explicitly set the pagination URL:

$data->paginate()->withPath('/my/url');

and it worked!

Please or to participate in this conversation.