mardi 24 avril 2018

Update URL from a blade view part

I'm looking on a way to update an url from blade. I want to sort a table, with two icons next to column's name. One to sort on ascending, the other on descending. My goal is to be able to add two parameters to the url, but to keep the original one first.

For exemple, I have this url :

localhost:8000/building

and by clicking on my icon I will get :

localhost:8000/building?sortingObject=name&sortingOrder=asc

but I also can have

localhost:8000/building?search=8

and by clicking on my icon I want to get :

localhost:8000/building?search=8&sortingObject=name&sortingOrder=asc

I tried this :

<a href="">
    <span class="glyphicon glyphicon-sort-by-attributes-alt text-secondary" aria-hidden="true"></span>
</a>

But it's really raw, it cumulates same parameters every time I click on a sort button, and it also needs to know if there is other parameters before (to choose between '&' or '?').

I saw some methods but it always needs to know every parameters to construct a new URL. Is there a way to do this directly in my blade file, or do I need to do this in my controller ?

Thanks by advance



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire