Skip to content

Commit 101a37f

Browse files
committed
Fix forced position detection in PositionObserver and allow composer require on any 5.* Laravel version
1 parent 40cc31f commit 101a37f

File tree

4 files changed

+13
-6
lines changed

4 files changed

+13
-6
lines changed

README.md

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,14 @@
11
# Laravel eloquent model position
2-
Position logic for Eloquent models with minimum setup. Before saving it will check if the position has changed
3-
and updates the other entries based on the models position value.
42

53
[![Total Downloads](https://poser.pugx.org/pion/laravel-eloquent-position/downloads?format=flat)](https://packagist.org/packages/pion/laravel-eloquent-position)
64
[![Latest Stable Version](https://poser.pugx.org/pion/laravel-eloquent-position/v/stable?format=flat)](https://packagist.org/packages/pion/laravel-eloquent-position)
75
[![Latest Unstable Version](https://poser.pugx.org/pion/laravel-eloquent-position/v/unstable?format=flat)](https://packagist.org/packages/pion/laravel-eloquent-position)
86

7+
8+
Position logic for Eloquent models with minimum setup. Before saving it will check if the position has changed
9+
and updates the other entries based on the models position value.
10+
11+
912
* [Installation](#installation)
1013
* [Usage](#usage)
1114
* [Migration example](#migration-example)
@@ -20,6 +23,8 @@ and updates the other entries based on the models position value.
2023

2124
## Installation
2225

26+
> Tested in Laravel 5.3 - 5.6, should work in all 5.* releases
27+
2328
**Install via composer**
2429

2530
```
@@ -164,4 +169,4 @@ See [CONTRIBUTING.md](CONTRIBUTING.md) for how to contribute changes. All contri
164169
was written by [Martin Kluska](http://kluska.cz) and is released under the
165170
[MIT License](LICENSE.md).
166171

167-
Copyright (c) 2016 Martin Kluska
172+
Copyright (c) 2016 Martin Kluska

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "pion/laravel-eloquent-position",
33
"description": "Position logic for Eloquent models with minimum setup",
44
"require": {
5-
"laravel/framework": "5.1.* || 5.2.* || 5.3.* || 5.4.* || 5.5.* || 5.6.*"
5+
"laravel/framework": "5.*"
66
},
77
"require-dev": {
88
"squizlabs/php_codesniffer": "2.*"

src/PositionObserver.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ protected function forcedPosition($model, $position, $oldPosition = null)
7373
$query = new PositionQuery($model, $position);
7474

7575
// Run the query
76-
$query->runQuery($query, $oldPosition);
76+
$this->runQuery($query, $oldPosition);
7777
}
7878

7979
/**
@@ -123,7 +123,7 @@ protected function runQuery(AbstractPositionQuery $query, $oldPosition)
123123
$eventResponse = $this->firePositioningEvent($query);
124124

125125
// Ignore updating the position and revert the position to original value
126-
if ($eventResponse !== $eventResponse && $eventResponse === false) {
126+
if ($eventResponse === false) {
127127
// Update the new position to original position
128128
$query->model()->setPosition($oldPosition);
129129
} else {

src/Query/PositionQuery.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
namespace Pion\Support\Eloquent\Position\Query;
44

5+
use Illuminate\Database\Eloquent\Builder;
56
use Illuminate\Database\Eloquent\Model;
67
use Pion\Support\Eloquent\Position\Traits\PositionTrait;
78

@@ -27,6 +28,7 @@ class PositionQuery extends AbstractPositionQuery
2728
* Creates the base query and builds the query
2829
*
2930
* @param Model|PositionTrait $model
31+
* @param int $position
3032
*/
3133
public function __construct($model, $position)
3234
{

0 commit comments

Comments
 (0)