A
A
Alexander2014-07-13 04:36:42
Laravel
Alexander, 2014-07-13 04:36:42

Laravel 4. Subcategories. What do you think is better?

I am writing a project on Laravel 4 (my first project on this framework). There is multilanguage and subcategories (depth up to 4 nesting categories). I think to implement by specifying the ID of the parent category of each category.
(category "bulka" id 2 parent id 1 "toster").
There is also the option of assigning a "tag" category (taxonomy).
How do you advise to implement this as laravel-way as possible, what alternative and better options do you suggest?

Answer the question

In order to leave comments, you need to log in

3 answer(s)
A
Alexander N++, 2014-07-24
@Aleks-NP

For categories, such things are
suitable Matherialized Path Convenient that each element knows the return path (1.4.6)
Nested Set is convenient in selecting a complete tree of entities, not convenient when the tree changes frequently.
In general, I recommend using Nested Set for categories,
and using Matherialized Path for records.
Then it will be very easy to make such selections
Select all records from category + category 1 > +

A
Andrey Sokolov, 2014-07-14
@eX1stenZ

can be implemented (hasMany|hasOne)
Here is a detailed description of how to do it:
laravel.ru/articles/odd_bod/eloquent-tutorial
I hope it helps =)

B
Big_Shark, 2014-07-17
@Big_Shark

Maybe it's better to use Nested Set? You can take this lib for example https://github.com/etrepat/baum

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question