From 030b5b5e2b3af28b16518f8c9d6affdca688c463 Mon Sep 17 00:00:00 2001 From: Freek Van der Herten Date: Sat, 1 Sep 2018 08:13:28 +0200 Subject: [PATCH 1/6] Update .styleci.yml --- .styleci.yml | 2 -- 1 file changed, 2 deletions(-) diff --git a/.styleci.yml b/.styleci.yml index 916d27e..0285f17 100644 --- a/.styleci.yml +++ b/.styleci.yml @@ -1,3 +1 @@ preset: laravel - -linting: true From e86bc499a10327cc9074ac51079aeed61d8f8e9e Mon Sep 17 00:00:00 2001 From: Freek Van der Herten Date: Sat, 1 Sep 2018 08:13:46 +0200 Subject: [PATCH 2/6] Update README.md --- README.md | 1 - 1 file changed, 1 deletion(-) diff --git a/README.md b/README.md index 0c3a420..663d889 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,6 @@ [![Latest Version](https://img.shields.io/github/release/spatie/eloquent-sortable.svg?style=flat-square)](https://github.com/spatie/eloquent-sortable/releases) -[![SensioLabsInsight](https://img.shields.io/sensiolabs/i/fb7765b9-7632-4897-8054-22d85b41ffda.svg)](https://insight.sensiolabs.com/projects/fb7765b9-7632-4897-8054-22d85b41ffda) [![Build Status](https://img.shields.io/travis/spatie/eloquent-sortable.svg?style=flat-square)](https://travis-ci.org/spatie/eloquent-sortable) [![Quality Score](https://img.shields.io/scrutinizer/g/spatie/eloquent-sortable.svg?style=flat-square)](https://scrutinizer-ci.com/g/spatie/eloquent-sortable) [![Software License](https://img.shields.io/badge/license-MIT-brightgreen.svg?style=flat-square)](LICENSE.md) From 762bacbec2cbce00e6613dac3e1b908cb83eabfa Mon Sep 17 00:00:00 2001 From: Freek Van der Herten Date: Tue, 18 Sep 2018 13:15:11 +0200 Subject: [PATCH 3/6] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 663d889..5bb8f29 100644 --- a/README.md +++ b/README.md @@ -21,7 +21,7 @@ Spatie is a webdesign agency in Antwerp, Belgium. You'll find an overview of all This package can be installed through Composer. ``` -$ composer require spatie/eloquent-sortable +composer require spatie/eloquent-sortable ``` ## Usage From 1f7014639f3690919ec27ddc91d34bbecfca5312 Mon Sep 17 00:00:00 2001 From: Freek Van der Herten Date: Tue, 18 Sep 2018 13:21:10 +0200 Subject: [PATCH 4/6] Update README.md --- README.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 5bb8f29..f0f9364 100644 --- a/README.md +++ b/README.md @@ -26,10 +26,10 @@ composer require spatie/eloquent-sortable ## Usage -To add sortable behaviour to your model you must:
-1. specify that the model will conform to ```Spatie\EloquentSortable\Sortable```
-2. use the trait ```Spatie\EloquentSortable\SortableTrait```
-3. specify which column will be used as the order column
+To add sortable behaviour to your model you must: +1. Implement the `Spatie\EloquentSortable\Sortable` interface. +2. Use the trait `Spatie\EloquentSortable\SortableTrait`. +3. Optionally specify which column will be used as the order column. The default is `order_column`. ### Example From 47f763d51d1ce1539dc73e8399d2b65ec13081b4 Mon Sep 17 00:00:00 2001 From: Alex Bowers Date: Thu, 18 Oct 2018 18:58:49 +0100 Subject: [PATCH 5/6] Travis PHP 7.3 (#65) --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index b95d9ac..ac208d1 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,9 +1,9 @@ language: php php: - - 7.0 - 7.1 - 7.2 + - 7.3 env: matrix: From e16a81e5b8c6ddfd6f0388681f9d185b06883f1b Mon Sep 17 00:00:00 2001 From: Yahav Date: Sun, 10 Feb 2019 03:16:53 +0200 Subject: [PATCH 6/6] Update README.md (#69) added grouping section --- README.md | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/README.md b/README.md index f0f9364..c62dc57 100644 --- a/README.md +++ b/README.md @@ -114,6 +114,19 @@ You can swap the order of two models: MyModel::swapOrder($myModel, $anotherModel); ``` +### Grouping + +If your model/table has a grouping field (usually a foreign key): `id, `**`user_id`**`, title, order_column` +and you'd like the above methods to take it into considerations, you can create a `buildSortQuery` method at your model: +```php + public function buildSortQuery() + { + return static::query()->where('user_id', $this->user_id); + } +``` +This will restrict the calculations to fields value of the model instance. + + ## Tests The package contains some integration/smoke tests, set up with Orchestra. The tests can be run via phpunit.