4
4
4sadly2022-03-23 16:19:35
PHP
4sadly, 2022-03-23 16:19:35

How to make such categories in laravel?

Category
    Sub-Category
        Sub-Sub-Category
            Sub-Sub-Sub-Category
            Sub-Sub-Sub-Category
            Sub-Sub-Sub-Category
            Sub-Sub-Sub-Category
        Sub-Sub-Category
            Sub-Sub-Sub-Category
            Sub-Sub-Sub-Category
            Sub-Sub-Sub-Category
            Sub-Sub-Sub-Category
    Sub-Category
        Sub-Sub-Category
            Sub-Sub-Sub-Category
            Sub-Sub-Sub-Category
            Sub-Sub-Sub-Category
            Sub-Sub-Sub-Category
Category
    Sub-Category


I want that when receiving the name attribute, for example, for a category
Category 1 -> Sub-Category 2 -> Sub-Sub-Category 1 -> Sub-Sub-Sub-Category 3

The name was 1.2.1.3 + nameof this category, the number should be entered automatically, and not taken from the names, perhaps it can be stored in the database and specified automatically when created

Answer the question

In order to leave comments, you need to log in

2 answer(s)
P
Pavel Gogolinsky, 2022-03-23
@4sadly

https://github.com/lazychaser/laravel-nestedset

M
markinigor, 2022-03-28
@markinigor

Another option via cte
https://github.com/staudenmeir/laravel-cte

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question