Code Monkey home page Code Monkey logo

Comments (8)

markomilivojevic avatar markomilivojevic commented on May 18, 2024 4

Another solution is to remove query from query string by calling ->appends('query', null) on your ->paginate() method.

from scout.

minkmk94 avatar minkmk94 commented on May 18, 2024 3

Actually @nunomaduro just made the remark that you can just call ->appends('query', "overwrite here") and it would overwrite the query parameter. In addition you can do something like ->appends('q', $query) if you want a different key.

In View i have Input name=search, and i use ->appends('search', request()->get('search'))->links() in bottom of view. But it still have ?query=something&search=something in my url, how can i remove param 'query' or customize it to 'search' ?

from scout.

Harry-Harrison avatar Harry-Harrison commented on May 18, 2024 1

Thank you everyone in this thread!

So to anyone else, if you want to use q for your query parameter, for instance if query is disallowed by any other packages... cough... You need to do this.

ModelName::search($request->q)->paginate(15)->appends('query', null)->appends('q', $request->q);

This will return your pagination urls without the query parameter and with the q parameter with the value of the request.

from scout.

powelski avatar powelski commented on May 18, 2024

This is great idea, but I think it would be even better to make it work with a closure. This way, we could make our URLs whatever we want. I like having /search/my-dog URLs. Some may argue that it's not standard compatible, but I like it.

from scout.

driesvints avatar driesvints commented on May 18, 2024

I can see this being useful. I'll try to send in a PR for this.

from scout.

driesvints avatar driesvints commented on May 18, 2024

Sent in a PR for this. Please provide feedback #311

from scout.

driesvints avatar driesvints commented on May 18, 2024

Actually @nunomaduro just made the remark that you can just call ->appends('query', "overwrite here") and it would overwrite the query parameter. In addition you can do something like ->appends('q', $query) if you want a different key.

from scout.

jenky avatar jenky commented on May 18, 2024

Actually @nunomaduro just made the remark that you can just call ->appends('query', "overwrite here") and it would overwrite the query parameter. In addition you can do something like ->appends('q', $query) if you want a different key.

It returns LengthAwarePaginator so appends should work, but why does it have to be hardcoded like that. If page name can be customized then this query should not be added by default.

from scout.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.