Laravel Livewire Multiple Pagination In One Page

Viewed 1118

I'm using Laravel Livewire and here I have 3 tables that showing on one page but the problem is the pagination showing correctly but not working(the URL change to http://127.0.0.1:8000/blogpost?EnPosts=3 but the table stays on page 1).

Livewire component class:

$En = LangBlog::where('id', '1')->first();
$Fa = LangBlog::where('id', '2')->first();
$Pa = LangBlog::where('id', '3')->first();

 return view('livewire.admin.blogs', [
        'EnPosts'     => $En->blogPosts()->paginate(1, ['*'], 'EnPosts'),
        'FaPosts'     => $Fa->blogPosts()->paginate(1, ['*'], 'FaPosts'),
        'PaPosts'     => $Pa->blogPosts()->paginate(1, ['*'], 'PaPosts'),
])->layout('layouts.master');

Livewire component view:

{{ $EnPosts->links('pagination.custom-pagination') }}
{{ $FaPosts->links('pagination.custom-pagination') }}
{{ $PaPosts->links('pagination.custom-pagination') }} 

these links are placed on the footer of every table.

1 Answers

May be helpful for you

$En = LangBlog::where('id', '1')->paginate(10); $Fa = LangBlog::where('id', '2')->paginate(10); $Pa = LangBlog::where('id', '3')->paginate(10);

return view('livewire.admin.blogs', [EnPosts' => $En,'FaPosts'=>$Fa,'PaPosts'=>$Pa]); in Component View {{ $EnPosts->links('pagination.custom-pagination') }} {{ $FaPosts->links('pagination.custom-pagination') }} {{ $PaPosts->links('pagination.custom-pagination') }}
Related