Skip to content

Commit 976569c

Browse files
committed
Updated docs
1 parent 21d8220 commit 976569c

File tree

4 files changed

+31
-15
lines changed

4 files changed

+31
-15
lines changed

CHANGELOG.markdown

+9
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,12 @@
1+
### 4.1.0
2+
3+
* Converted to trait
4+
* Methods were renamed:
5+
- `appendTo` to `appendToNode`
6+
- `prependTo` to `prependToNode`
7+
- `insertBefore` to `insertBeforeNode`
8+
- `insertAfter` to `insertAfterNode`
9+
110
### 3.1.1
211

312
* Fixed #42: model becomes dirty before save when parent is changed and using `appendTo`,

README.markdown

+12-13
Original file line numberDiff line numberDiff line change
@@ -70,8 +70,7 @@ If model is successfully saved it doesn't mean that node has moved. If your appl
7070
depends on whether the node has actually changed its position, use `hasMoved` method:
7171

7272
```php
73-
if ($node->save())
74-
{
73+
if ($node->save()) {
7574
$moved = $node->hasMoved();
7675
}
7776
```
@@ -108,7 +107,7 @@ There are few ways to append a node:
108107

109108
```php
110109
// #1 Using deferred insert
111-
$node->appendTo($parent)->save();
110+
$node->appendToNode($parent)->save();
112111

113112
// #2 Using parent node
114113
$parent->appendNode($node);
@@ -131,7 +130,7 @@ And only a couple ways to prepend:
131130

132131
```php
133132
// #1
134-
$node->prependTo($parent)->save();
133+
$node->prependToNode($parent)->save();
135134

136135
// #2
137136
$parent->prependNode($node);
@@ -150,8 +149,8 @@ $node->afterNode($neighbor)->save();
150149
$node->beforeNode($neighbor)->save();
151150

152151
# Implicit save
153-
$node->insertAfter($neighbor);
154-
$node->insertBefore($neighbor);
152+
$node->insertAfterNode($neighbor);
153+
$node->insertBeforeNode($neighbor);
155154
```
156155

157156
#### Shifting a node
@@ -461,8 +460,7 @@ composer require kalnoy/nestedset
461460
You can use a method to add needed columns with default names:
462461

463462
```php
464-
Schema::create('table', function (Blueprint $table)
465-
{
463+
Schema::create('table', function (Blueprint $table) {
466464
...
467465
NestedSet::columns($table);
468466
});
@@ -471,8 +469,7 @@ Schema::create('table', function (Blueprint $table)
471469
To drop columns:
472470

473471
```php
474-
Schema::table('table', function (Blueprint $table)
475-
{
472+
Schema::table('table', function (Blueprint $table) {
476473
NestedSet::dropColumns($table);
477474
});
478475
```
@@ -489,11 +486,13 @@ $table->index([ '_lft', '_rgt', 'parent_id' ]);
489486

490487
### The model
491488

492-
Your model is now extended from `Kalnoy\Nestedset\Node` class, not `Eloquent`:
489+
Your model should use `Kalnoy\Nesetedset\NodeTrait` trait to enable nested sets:
493490

494491
```php
495-
class Foo extends Kalnoy\Nestedset\Node {
496-
492+
use Kalnoy\Nesetedset\NodeTrait;
493+
494+
class Foo extends Model {
495+
use NodeTrait;
497496
}
498497
```
499498

TODO.markdown

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
* Fix `parent_id` not getting dirty after assignment before hitting `save`
2-
* Implement tree restoring algorithm
1+
* Convert query builder to extension
2+
* Implement tree update algorithm

UPGRADE.markdown

+8
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,11 @@
1+
### Upgrading from 4.0 to 4.1
2+
3+
Nested sets feature has been moved to trait `Kalnoy\Nesetedset\NodeTrait`, but
4+
old `Kalnoy\Nesetedset\Node` class is still available.
5+
6+
Some methods on trait were renamed (see changelog), but still available on legacy
7+
node class.
8+
19
### Upgrading to 3.0
210

311
Some methods were renamed, see changelog for more details.

0 commit comments

Comments
 (0)