Surya Matadewa
Surya Matadewa

Reputation: 1027

laravel paginate passing additional var

let say i have url like this

http://localhost:8080/myweb/listproduct?idcategory=3

but when i used laravel pagination link, my passing variabel by url disappear like this

http://localhost:8080/myweb/listproduct?page=2

i want laravel paginate to pass my url variable too like this

http://localhost:8080/myweb/listproduct?idcategory=3&page2

so far i already try to set baseurl like this

$listproduct = DB::table('product')->paginate(15);
$users->setBaseUrl('listproduct?idcategory=3');

but the result is like this (? not &)

http://localhost:8080/myweb/listproduct?idcategory=3?page2

i used laravel 4.2

Upvotes: 1

Views: 120

Answers (2)

Mohamed Bouallegue
Mohamed Bouallegue

Reputation: 1362

you can use setPath()

$users->setPath('listproduct?idcategory=3');

or if you only want to add to the query string you may use

$users->appends(['idcategory' => '3'])

Upvotes: 1

Tim L
Tim L

Reputation: 175

You can use this method to append more arguments to your pagination link:

 $listproduct->appends(['idcategory' => $id])->links();

Upvotes: 1

Related Questions