I created my Laravel application with version 5.7 and I also have a Laravel tenancy setup. Here is my controller:
public function index()
{
$admins = SystemAdmin::latest()->paginate(1);
return view('my.admin.settings.admins.index', compact('admins'));
}
and my code on the view where the pagination links are (blade):
<div class="row">
<div class="col">
<div class="pagination center">
{{ $admins->links() }}
</div>
</div>
</div>
The pagination shows but when I click the links it redirects to the page with the URL bar showing ?page=2 or 3 whatever I clicked, but the 1 value stays highlighted as "active" and the lastest() value, as I called, is the only one that shows since I am only paginating 1 at a time.
UPDATE:::::
I dd() the {{ $admins->links() }} and this is what I get:
HtmlString {#368 ▼
#html: """
<ul class="pagination" role="navigation">
<li class="page-item disabled" aria-disabled="true" aria-label="« Previous">
<span class="page-link" aria-hidden="true">‹</span>
</li>
<li class="page-item active" aria-current="page"><span class="page-link">1</span></li>
<li class="page-item"><a class="page-link" href="https://my.distincttrack.com/ad ▶
<li class="page-item"><a class="page-link" href="https://my.distincttrack.com/ad ▶
<li class="page-item"><a class="page-link" href="https://my.distincttrack.com/ad ▶
<li class="page-item">
<a class="page-link" href="https://my.distincttrack.com/admin/settings/admins?page=2" rel="next" aria-label="Next »">›</a>
</li>
</ul>
"""
}
dd($admins->links())
inindex
method for two different pages? – Ahmed Nour Jamal El-Din