I'm giving a custom page name "p_role" using setPageName method, as I want use multiple pagination on a single page.
But when I set a custom page name ($roles->setPageName('p_role');
), rendered (twitter-bootstrap pagination) links are not working.
It works fine if default page name "page" is set as custom page name ($roles->setPageName('page');
)
So how can I set custom page names in laravel 5 pagination.
AccessController.php
use App\Http\Controllers\Controller;
use App\Models\Role;
class AccessController extends Controller {
public function getRole()
{
$roles = Role::paginate(1);
$roles->setPageName('p_role');
return view('role', compact('roles'));
}
}
role.blade.php
<div>
<ol>
@foreach($roles as $role)
<li>
{{$role->name}}
</li>
@endforeach
</ol>
{!! $roles->render() !!}
</div>
Output:these links are not working, used $roles->setPageName('p_role') to set page name.
<ul class="pagination">
<li class="disabled"><span>«</span></li>
<li class="active"><span>1</span></li>
<li><a href="http://five/access/roles/?p_role=2">2</a></li>
<li><a href="http://five/access/roles/?p_role=2" rel="next">»</a></li>
These links works fine, used $roles->setPageName('page') to set page name.
<ul class="pagination">
<li class="disabled"><span>«</span></li>
<li class="active"><span>1</span></li>
<li><a href="http://five/access/roles/?page=2">2</a></li>
<li><a href="http://five/access/roles/?page=2" rel="next">»</a></li>
</ul>
</ul>