A
A
Alex_Creo2016-05-23 16:47:48
RESTful API
Alex_Creo, 2016-05-23 16:47:48

How to organize filter/search URLs and routes for Laravel?

There is a real estate catalog. Now work with collections goes through Rest controllers - Route::resource(name,controller)
example.com/house/{id} - issuing a daily rent object
example.com/rent/{id} - issuing a long-term rent object
There is a search functionality / filters that calls the filter method, the filter controller, to which the search request is passed via get/post and the output is generated.
example.com/filter?district=districtName&
subway=subwayName&
room=roomCount&
people=peopleCount&
orderBy=orderByValue&
priceMin=priceMinValue&
priceMax=priceMaxValue&
city=cityName
After the SEO audit, we set a task - to change the organization of the URL in the filters. Make it like on OLX or similar.
olx.ua/kiev/
olx.ua/hobbi-otdyh-i-sport/kiev/
olx.ua/hobbi-otdyh-i-sport/muzykalnye-instrumenty/kiev/
In my case, these should be links like
example.com/ posutochno/kiev/2-room
example.com/dolgosrochno/2-room
example.com/posutochno/kiev/obolon/metro-obolon/4-spalnih-mest
example.com/posutochno/kiev/4-spalnih-mest
I can describe full nesting if necessary
The documentation seems to suggest the following, but the links will still be long:
Route::get('posts/{post?}/comments/{comment?}', function ($postId = null, $commentId = null ) {
//
});
What is the most correct approach to organize url and routes in my case?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
T
Timofey, 2016-05-23
@mr_T

And what, exactly, is the problem? After all, you can leave the old filtering method and add a new one.
From an SEO point of view, this is unlikely to affect anything, since search engines will not submit forms.
And so create a route like Route::get('/catalog/{segment1?}/{segment2?}', '[email protected]'), where to somehow match the segments and limit the selection by them.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question