Download the PHP package easydot/nested-categories without Composer
On this page you can find all versions of the php package easydot/nested-categories. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Informations about the package nested-categories
nested-categories
Forked from denis-kisel/nested-categories
This library provide optimize common usage categories functional, such as: category tree, breadcrumbs, child category items by one sql query
Support for
mysql5.7.22+
laravel
php8.0+
Install package
Install via composer
Install or upgrade Category table
If you have not yet category table, install it:
If you have category table already, just upgrade it:
Suppose what your table has fields: id, parent_id
Configure
Add trait NestableCategory to category model
Add path to fillable or set guarded
[Optional]
Add trait AutoRebuildNested to category model for auto rebuild category structure after events: created, updated, deleted.
BUT ITS DONT AUTO REBUILD AFTER BATCH OPERATION(see Rebuild Structure).
Background use one query for rebuild all table
Usage
Tree As Array
| id | parent_id | name | order |
|---|---|---|---|
| 1 | NULL | Parent | 0 |
| 2 | 1 | Child1 | 0 |
| 3 | 1 | Child2 | 1 |
Breadcrumbs
Backend use one sql query for N nested categories
Leafs/child category items(Nested Products, Posts, Podcasts, etc..)
Input tables: categories(id, parent_id, name), products(id, category_id, name).
Backend use one sql query for nested leafs
Rebuild Structure
After BATCH CRUD operations for rebuild categories structure, need to use rebuild method.
Or you can use trait AutoRebuildNested after single operation(see more in Configure)
Background use one query for rebuild all table