4

When I use form I have that URL

view-source:http://teory.loc/realty/appartment_rent/day?city=&district=&cost_up=29999&cost_to=333333&rooms_up=&rooms_to=&area_up=&area_to=&floor_up=&floor_to=

for example

To handle this URL I used that code

 public static function search($paginate, $condotions = null, $order = null){



    return AppartmentRentDay::where(function ($query) use ($condotions){
        foreach ($condotions as $key => $value){
            if($value){
                $parametrs = [];
                if(substr($key,-3) == "_up"){
                    $parametrs[0] = substr($key,0,-3);
                    $parametrs[1] = '>=';
                }elseif (substr($key,-3) == "_to"){
                    $parametrs[1] = '<=';
                    $parametrs[0] = substr($key,0,-3);
                }else{
                    $parametrs[0] = $key;
                    $parametrs[1] = '=';
                }
                $query->where($parametrs[0], $parametrs[1], $value);
            }
        }
    })->paginate($paginate);

}

Paginate works right, but {{ $info->links() }} what gives for that hrefs

<ul class="pagination">
           <li class="disabled"><span>&laquo;</span></li>
           <li class="active"><span>1</span></li>                                                                                
           <li><a href="http://teory.loc/realty/appartment_rent/day?page=2">2</a></li>
           <li><a href="http://teory.loc/realty/appartment_rent/day?page=2" rel="next">&raquo;</a></li>
        </ul>

And that works incorrect, how to add my get parameters for this href?

Plz give me some info Ty Laravel 5.5

1
  • Please include the url in the post itself as text. Commented Oct 4, 2017 at 18:11

1 Answer 1

15

You can append the existing parameters to the links like this:

AppartmentRentDay::where(...)->paginate($paginate)->appends(request()->except('page'));
Sign up to request clarification or add additional context in comments.

2 Comments

thank you very much, that works, if you can give me some url when i can read about that
The documentation is a great place to start. Scroll down to the section titled "Appending To Pagination Links"

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.