diff --git a/database-traits.md b/database-traits.md index 86b755bc..9bbbe4f3 100644 --- a/database-traits.md +++ b/database-traits.md @@ -6,6 +6,7 @@ - [Sluggable](#sluggable) - [Revisionable](#revisionable) - [Sortable](#sortable) +- [HasSortableRelations](#has-sortable-relations) - [Simple Tree](#simple-tree) - [Nested Tree](#nested-tree) - [Validation](#validation) @@ -676,3 +677,20 @@ class Product extends Model protected $nullable = ['sku']; } ``` + + +## HasSortableRelations + +Add this trait to your model in order to allow its relations to be sorted/reordered. + +```php +class MyModel extends model +{ + use \Winter\Storm\Database\Traits\HasSortableRelations; + + /** + * @var array Relations that can be sorted/reordered and the column name to use for sorting/reordering. + */ + public $sortableRelations = ['relation_name' => 'sort_order_column']; +... +}