L
L
lolrofl012021-05-09 23:20:27
Laravel
lolrofl01, 2021-05-09 23:20:27

How are hierarchical routes built in Lara and what processing logic do you recommend?

Good afternoon. There is a site with:
1) Posts
2) Products
3) Categories (in large numbers)
4) Pages
5) Media (any links to videos)

The site used to be on WordPress, so all the URLs are in the index and they are all of the same type:
site.ru /query, where query can be anything, even a page, even a post, even a category or vidos, or maybe it's a product. The situation is further aggravated by the fact that there are 3 levels of categories, and the URL in their case is formed like this:
site.ru/cat/query or site.ru/cat/cat/cat/query.
You can also open categories, which can be of the form site.ru/cat and site.ru/cat/cat and site.ru/cat/cat/cat.

So, pros, how would you implement such routing?)

I racked my brains for an hour and came to the following questions:
1) Will the query check for all tables slow down the page? After all, we initially do not know what the user is requesting, and we cannot change the url in any way, because it is already in the index. What is the easiest way to immediately give the user what he came for?

2) Do you need to use nestedset for categories? Can it be done in another way? It seems like it comes to the hierarchy - everyone screams about nested. But I really do not want to change the application logic, add additional fields to the tables. And in general, at the stage of 70% completion of the project, it is very scary to add other people's packages. Even if everything is great, you never know at what stage it will bring surprises.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
K
Konstantin B., 2021-05-10
@Kostik_1993

1) yes
2) if you don’t like it, use whatever you want, how can we know what might suit you
?

P
pLavrenov, 2021-05-11
@pLavrenov

You can also follow the path of the "ancestors" and make 301 redirects from old links to new ones and they will be replaced in the search results themselves.
Or read about "laravel recursive relationship"

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question