Foks's avatar
Level 15

Multiple Paginations on one page

Hi! I'm currently looking for a way to have multiple paginations on a single page, with they are interfering with each other. How can I do that?

Best Regards, Foks

0 likes
12 replies
MichalOravec's avatar

You have to set different $pageName in paginate method which is third parameter

public function paginate($perPage = null, $columns = ['*'], $pageName = 'page', $page = null)

For example

$articles = Article::paginate(10, ['*'], 'articles');

$posts = Post::paginate(10, ['*'], 'posts');
3 likes
Shashi Mehta's avatar

Thanks - for a clearly understood and accurate description / solution

Foks's avatar
Level 15

This is how I have it right now, after your comment, but it doesn't seem to work?

        $transactions = Transaction::where('customer_id', $this->client->id)->paginate(1, ['*'], 'transactions');
        $invoices = Invoice::where('customer_id', $this->client->id)->paginate(1, ['*'], 'invoices');
        return view('livewire.client.components.details',[
            'transactions' => $transactions,
            'invoices' => $invoices
        ]);
jlrdw's avatar

If you are using livewire / ajax just use two different divisions and paginate with ajax.

Foks's avatar
Level 15

Can you explain what you mean by that?

Snapey's avatar
Snapey
Best Answer
Level 122

Livewire pagination may not support it?

In the generated links, can you see each of the paginator names? (view source in the browser)

1 like
Foks's avatar
Level 15

I'm only using Livewire & AlpineJS from Jetstream

Foks's avatar
Level 15

Seems like it is livewire that fucks it up :(

Please or to participate in this conversation.