Please look into my code, this is my web.php
Route::get('test', function (Request $request) {
$data = MyTableResource::collection(MyTable::paginate(10));
$headers = ['col1', 'col2', 'col3'];
return view('test.index', compact('data', 'headers'));
});
Here is my blade file,
<table md-table>
<thead>
<tr>
@foreach($headers as $header)
<th><span>{{$header}}</span></th>
@endforeach
</tr>
</thead>
<tbody>
@foreach($data as $d)
<tr>
<td>{{$d->id}}</td>
<td>{{$d->primary_identifier}}</td>
<td>{{$d->order_date}}</td>
</tr>
@endforeach
</tbody>
</table>
<div class = "table-paginate">
{{ $orders->links() }}
</div>
My problem is that,
when I refresh my page, the URL is
http://localhost/test?page=1
And when I click on any link, the URL is just replacing with its number (http://localhost/test?page=2
), not redirecting.
I inspect the pagination link, it seems like
<li class="page-item" aria-current="page">
<a class="page-link" href="http://amzmarketplace.localhost.tom/test?page=2">2</a>
</li>
It is working when I added and attribute to <a>
tag, that target="_self"
.
But how can I add this attribute in Laravel pagination URL or is there any other way to solve this issue?