Question

$dbDetails= Contract::where( 'a', 'LIKE', "%$searchText%" )
            ->orWhere( 'b', 'LIKE', "%$searchText%" )
            ->orWhere( 'c', 'LIKE', "%$searchText%" )
            ->orWhere( 'd', 'LIKE', "%$searchText%" )
            ->paginate($paginationNumber);

This is my controller and am getting the pagination links in view by using

{{ $contractDetails->appends(array('search' => 'test'))->links() }}

So here is how my url looks like

domain.com/search?page=2&search=test

Iam wondering how can i get the second page with 10 number of rows?

Can anyone help me to solve this?
Thanks in advance

Was it helpful?

Solution

I would say pas the value 10 as a get parameter, read it and pass it to paginate->().

$dbDetails= Contract::where( 'a', 'LIKE', "%$searchText%" )
            ->orWhere( 'b', 'LIKE', "%$searchText%" )
            ->orWhere( 'c', 'LIKE', "%$searchText%" )
            ->orWhere( 'd', 'LIKE', "%$searchText%" )
            ->paginate(Input::get('paginate'));

This is my controller and am getting the pagination links in view by using

{{ $contractDetails->appends(array('search' => 'test', 'paginate' => 10))->links() }}

So here is how my url should look like

domain.com/search?page=2&search=test&paginate=10

If I understand correctly this is what u want.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top