I am creating a dynamic query depending on user's form selections and diplaying the query result as paginated.
$query = 'v.id';
if($model == 1){
$query .= ' ,v.model';
}
if($marka == 1){
$query .= ' ,v.brand_name';
}
if($plaka == 1){
$query .= ' ,v.licenseplate';
}
if($fiyat == 1){
$query .= ' ,v.buying_price';
}
.
.
.
$query_result = DB::table('vehicles AS v')
->selectRaw($query)
->paginate(25);
The problem is, once i click to pagination links page is refreshing and dynamic query backs to its initial value so most of the data gets missed. I tried to use appends()
but couldnt find a proper solution so far. Any help would be appreciated.
Append $_GET parameters to your paginator:
$query_result = DB::table('vehicles AS v')
->selectRaw($query)
->appends( \Input::all() )
->paginate(25);
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.