G
G
GrimJack2017-05-16 22:01:06
Laravel
GrimJack, 2017-05-16 22:01:06

How to get automatic full route??

In general, I have not come across it before and I don’t know how to google it correctly. Let me explain with an example:
there is a store site.ru/store (prefix)
there are categories in it site.ru/store/{$category}(prefix)
there are goods site.ru/store/{$category}/{$id}
As correct get a route anywhere in the application? So as not to produce duplicates, etc.
The product has type links with categories and so on, but it seems to me that "calculating" by links is not too correct, or am I being driven?
Please don't drop your boots.
PS and if the product is in several categories, how then? Count it first?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
K
Konstantin B., 2017-05-16
@Kostik_1993

No, the product must have its own address, not tied to categories

E
Elnur Urazymbetov, 2017-05-16
@u_elnur

If a product can be associated with several categories and you want to reflect this in the route, then there will be duplicates anyway.
I see two options:
First: Don't show the category in the route.
For example, a category route: /store/category/{$category-id} A
product route: /store/product/{$product-id}
Instead of id, you can insert a transliteration of the product or category name. Or both id and transliteration
Second: Each product must have a main associated category. And show it in the route. And other categories will be just an addition inside the site and will not be reflected in the route in any way.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question