Skip to content

Commit 9b1a287

Browse files
WebVPFmjauvin
andauthored
Traits - Simple Tree - Add migration (#230)
Co-authored-by: Marc Jauvin <[email protected]>
1 parent e661c15 commit 9b1a287

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

database/traits.md

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,15 @@ $user->setSortableOrder([1, 2, 3], [3, 2, 1]);
207207
208208
## Simple Tree
209209

210-
A simple tree model will use the `parent_id` column maintain a parent and child relationship between models. To use the simple tree, apply the `Winter\Storm\Database\Traits\SimpleTree` trait.
210+
A simple tree model will use the `parent_id` column maintain a parent and child relationship between models. To add the `parent_id` column to your table, you may use the `unsignedInteger` method inside a migration.
211+
212+
```php
213+
Schema::table('categories', function ($table) {
214+
$table->unsignedInteger('parent_id')->nullable();
215+
});
216+
```
217+
218+
To use the simple tree, apply the `Winter\Storm\Database\Traits\SimpleTree` trait.
211219

212220
```php
213221
class Category extends Model

0 commit comments

Comments
 (0)