Skip to content

Commit c7c18d2

Browse files
Update README.md
1 parent 7cc1f88 commit c7c18d2

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

README.md

+14
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,20 @@ composer require michielkempen/nova-order-field
2626
3. Add a public static property called `$defaultOrderField` to your resource, containing your order column.
2727
4. Add the `OrderField` to your Nova Resource `fields` method.
2828

29+
### Grouping
30+
31+
If your model/table has a grouping field (usually a foreign key): `id, `**`user_id`**`, title, order_column`
32+
and you'd like the above methods to take it into considerations, you can create a `buildSortQuery` method at your model:
33+
34+
```php
35+
public function buildSortQuery()
36+
{
37+
return static::query()->where('user_id', $this->user_id);
38+
}
39+
```
40+
41+
This will restrict the calculations to fields value of the model instance.
42+
2943
### Example
3044

3145
```php

0 commit comments

Comments
 (0)