samedi 24 mars 2018

Laravel Create an Url from a form action with input value

Im developing an Ecommerce website using Algolia as the search provider. Algolia provides a widget to create a Searchbox, and that searchbox works like a charm when you are in the same page:

search.addWidget(
  instantsearch.widgets.searchBox({
    container: '#q',
    placeholder: 'Search for products',
    autofocus: false,
    poweredBy: true,
    reset: true,
    loadingIndicator: false
  })
);

But an ecommerce website usually displays a searchbox in header in all webpages consequently that widget could not be used globally (or I cant find the way).

Im trying to create a form action to send queries to controller search with function query:

    <form action="" method="get">
        <input id="q" class="form-control" type="text" placeholder="Search product by name or reference...">
    </form>

The URL that I have to send is like: http://example.com/search/query?q=apple

But i cannot find the way to take that input directly instead of creating a route and a controller. My idea is to see if its possible to:

  • Create an url directly on the fly.
  • Some way to use AppServiceProvider boot method to make it globally available.

best regards,



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire