8
8
9
9
<p align =" center " >
10
10
<a href="https://www.php.net/releases/8.1/en.php" target="_blank">
11
- <img src="https://img.shields.io/badge/PHP- %3E%3D8.1-787CB5 " alt="PHP Version ">
11
+ <img src="https://img.shields.io/badge/%3E%3D8.1-777BB4.svg?style=for-the-badge&logo=php&logoColor=white " alt="PHP version ">
12
12
</a>
13
13
<a href="https://github.com/yiisoft/yii2/tree/2.0.53" target="_blank">
14
- <img src="https://img.shields.io/badge/Yii2%20- 2.0.53-blue " alt="Yii2 2.0.53 ">
14
+ <img src="https://img.shields.io/badge/2.0.x-0073AA.svg?style=for-the-badge&logo=yii&logoColor=white " alt="Yii 2.0.x ">
15
15
</a>
16
16
<a href="https://github.com/yiisoft/yii2/tree/22.0" target="_blank">
17
- <img src="https://img.shields.io/badge/Yii2%20-22-blue " alt="Yii2 22.0">
17
+ <img src="https://img.shields.io/badge/22.0.x-0073AA.svg?style=for-the-badge&logo=yii&logoColor=white " alt="Yii 22.0.x ">
18
18
</a>
19
19
<a href="https://github.com/yii2-extensions/nested-sets-behavior/actions/workflows/build.yml" target="_blank">
20
- <img src="https://github.com/ yii2-extensions/nested-sets-behavior/actions/workflows/ build.yml/ badge.svg " alt="PHPUnit">
20
+ <img src="https://img.shields.io/github/actions/workflow/status/ yii2-extensions/nested-sets-behavior/build.yml?style=for-the- badge&label=PHPUnit " alt="PHPUnit">
21
21
</a>
22
22
<a href="https://dashboard.stryker-mutator.io/reports/github.com/yii2-extensions/nested-sets-behavior/main" target="_blank">
23
- <img src="https://img.shields.io/endpoint?style=flat &url=https%3A%2F%2Fbadge-api.stryker-mutator.io%2Fgithub.com%2Fyii2-extensions%2Fnested-sets-behavior%2Fmain" alt="Mutation Testing">
24
- </a>
25
- <a href="https://github.com/yii2-extensions/nested-sets-behavior/actions/workflows/static.yml" target="_blank">
26
- <img src="https://github.com/ yii2-extensions/nested-sets-behavior/actions/workflows/ static.yml/ badge.svg " alt="Static Analysis ">
27
- </a>
23
+ <img src="https://img.shields.io/endpoint?style=for-the-badge &url=https%3A%2F%2Fbadge-api.stryker-mutator.io%2Fgithub.com%2Fyii2-extensions%2Fnested-sets-behavior%2Fmain" alt="Mutation Testing">
24
+ </a>
25
+ <a href="https://github.com/yii2-extensions/nested-sets-behavior/actions/workflows/static.yml" target="_blank">
26
+ <img src="https://img.shields.io/github/actions/workflow/status/ yii2-extensions/nested-sets-behavior/static.yml?style=for-the- badge&label=PHPStan " alt="PHPStan ">
27
+ </a>
28
28
</p >
29
29
30
30
A powerful behavior for managing hierarchical data structures using the nested sets pattern in Yii ActiveRecord models.
@@ -49,15 +49,7 @@ with high-performance database operations.
49
49
[ ![ PostgreSQL] ( https://img.shields.io/badge/postgresql-4169e1?style=for-the-badge&logo=postgresql&logoColor=white )] ( https://github.com/yii2-extensions/nested-sets-behavior/actions/workflows/build-pgsql.yml )
50
50
[ ![ SQLite] ( https://img.shields.io/badge/sqlite-003B57.svg?style=for-the-badge&logo=sqlite&logoColor=white )] ( https://github.com/yii2-extensions/nested-sets-behavior/actions/workflows/build.yml )
51
51
52
- ## Quick start
53
-
54
- ### Installation
55
-
56
- ``` bash
57
- composer require yii2-extensions/nested-sets-behavior
58
- ```
59
-
60
- ### How it works
52
+ ## How it works
61
53
62
54
The nested sets model is a technique for storing hierarchical data in a relational database. Unlike adjacency lists
63
55
(parent_id approach), nested sets enable efficient tree operations with minimal database queries.
@@ -67,7 +59,7 @@ The nested sets model is a technique for storing hierarchical data in a relation
67
59
3 . ** Optimizes queries** using boundary values for efficient tree traversal.
68
60
4 . ** Supports transactions** to ensure data integrity during complex operations.
69
61
70
- #### Why nested sets?
62
+ ** Why nested sets?**
71
63
72
64
- ** Fast queries** : Get all descendants with a single query (` lft BETWEEN parent.lft AND parent.rgt ` ).
73
65
- ** Efficient tree operations** : No recursive queries needed for tree traversal.
@@ -86,6 +78,12 @@ Electronics (1,12,0)
86
78
Numbers represent: (left, right, depth)
87
79
```
88
80
81
+ ### Installation
82
+
83
+ ``` bash
84
+ composer require yii2-extensions/nested-sets-behavior
85
+ ```
86
+
89
87
### Database setup
90
88
91
89
The package includes ready-to-use migrations for creating the necessary database structure.
@@ -168,7 +166,7 @@ CREATE INDEX idx_multiple_tree_depth ON multiple_tree (depth);
168
166
CREATE INDEX idx_multiple_tree_tree_lft_rgt ON multiple_tree (tree, lft, rgt);
169
167
```
170
168
171
- ### Basic Configuration
169
+ ### Quick start
172
170
173
171
Add the behavior to your ActiveRecord model.
174
172
@@ -215,8 +213,6 @@ class Category extends ActiveRecord
215
213
}
216
214
```
217
215
218
- ### Basic Usage
219
-
220
216
#### Creating and building trees
221
217
222
218
``` php
@@ -304,7 +300,7 @@ $phones->delete();
304
300
$phones->deleteWithChildren();
305
301
```
306
302
307
- ### Query builder integration
303
+ #### Query builder integration
308
304
309
305
Add query behavior for advanced tree queries.
310
306
@@ -364,21 +360,24 @@ For detailed configuration options and advanced usage.
364
360
- 💡 [ Usage Examples] ( docs/examples.md )
365
361
- 🧪 [ Testing Guide] ( docs/testing.md )
366
362
363
+ ## Package information
364
+
365
+ [ ![ Latest Stable Version] ( https://img.shields.io/packagist/v/yii2-extensions/nested-sets-behavior.svg?style=for-the-badge&logo=packagist&logoColor=white&label=Stable )] ( https://packagist.org/packages/yii2-extensions/nested-sets-behavior )
366
+ [ ![ Total Downloads] ( https://img.shields.io/packagist/dt/yii2-extensions/nested-sets-behavior.svg?style=for-the-badge&logo=packagist&logoColor=white&label=Downloads )] ( https://packagist.org/packages/yii2-extensions/nested-sets-behavior )
367
+
367
368
## Quality code
368
369
369
- [ ![ Latest Stable Version] ( https://poser.pugx.org/yii2-extensions/nested-sets-behavior/v )] ( https://github.com/yii2-extensions/nested-sets-behavior/releases )
370
- [ ![ Total Downloads] ( https://poser.pugx.org/yii2-extensions/nested-sets-behavior/downloads )] ( https://packagist.org/packages/yii2-extensions/nested-sets-behavior )
371
- [ ![ codecov] ( https://codecov.io/gh/yii2-extensions/nested-sets-behavior/graph/badge.svg?token=Upc4yA23YN )] ( https://codecov.io/gh/yii2-extensions/nested-sets-behavior )
372
- [ ![ phpstan-level] ( https://img.shields.io/badge/PHPStan%20level-max-blue )] ( https://github.com/yii2-extensions/nested-sets-behavior/actions/workflows/static.yml )
373
- [ ![ style-ci] ( https://github.styleci.io/repos/717718161/shield?branch=main )] ( https://github.styleci.io/repos/717718161?branch=main )
370
+ [ ![ codecov] ( https://img.shields.io/codecov/c/github/yii2-extensions/nested-sets-behavior.svg?style=for-the-badge&logo=codecov&logoColor=white&label=Coverage )] ( https://codecov.io/gh/yii2-extensions/nested-sets-behavior )
371
+ [ ![ phpstan-level] ( https://img.shields.io/badge/PHPStan%20level-max-blue?style=for-the-badge )] ( https://github.com/yii2-extensions/nested-sets-behavior/actions/workflows/static.yml )
372
+ [ ![ style-ci] ( https://img.shields.io/badge/StyleCI-Passed-44CC11.svg?style=for-the-badge&logo=styleci&logoColor=white )] ( https://github.styleci.io/repos/717718161?branch=main )
374
373
375
374
## Our social networks
376
375
377
- [ ![ X] ( https://img.shields.io/badge/follow-@terabytesoftw -1DA1F2? logo=x&logoColor=1DA1F2 &labelColor=555555&style=flat )] ( https://x.com/Terabytesoftw )
376
+ [ ![ Follow on X] ( https://img.shields.io/badge/-Follow%20on%20X -1DA1F2.svg?style=for-the-badge& logo=x&logoColor=white &labelColor=000000 )] ( https://x.com/Terabytesoftw )
378
377
379
378
## License
380
379
381
- [ ![ License] ( https://img.shields.io/github/license/yii2-extensions/nested-sets-behavior )] ( LICENSE.md )
380
+ [ ![ License] ( https://img.shields.io/github/license/yii2-extensions/nested-sets-behavior?style=for-the-badge&logo=opensourceinitiative&logoColor=white&labelColor=333333 )] ( LICENSE.md )
382
381
383
382
## Fork
384
383
0 commit comments