Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions database-traits.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
- [Sluggable](#sluggable)
- [Revisionable](#revisionable)
- [Sortable](#sortable)
- [HasSortableRelations](#has-sortable-relations)
- [Simple Tree](#simple-tree)
- [Nested Tree](#nested-tree)
- [Validation](#validation)
Expand Down Expand Up @@ -676,3 +677,20 @@ class Product extends Model
protected $nullable = ['sku'];
}
```

<a name="hassortablerelations"></a>
## 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'];
...
}