eddy1992's avatar

how to remove ? from pagination

Hi I want to remove and replace the ? from the pagination

$products = Product::whereHas('categories', function($query) use ($categoryIds)
        {
            $query->whereIn('category_id', $categoryIds);
        })->paginate(16)->setPath($this->getCategoryId().'?level='.Input::get('level'));

now what it gives is http://localhost:8000/category/24?level=parent?page=2 but instead I want to replace ? with & it with http://localhost:8000/category/24?level=parent&page=2

0 likes
3 replies
martinbean's avatar
Level 80

@eddy1992 You’re better off appending your query string to the paginator, rather than trying to override the path (which is why you’re getting two ?s in your URLs):

$products = Product::whereHas('categories', function ($query) use ($categoryIds) {
    $query->whereIn('category_id', $categoryIds);
})->paginate(16)->appendArray($request->query());

Please or to participate in this conversation.