Skip to content

Commit

Permalink
Fix forced position detection in PositionObserver and allow composer …
Browse files Browse the repository at this point in the history
…require on any 5.* Laravel version
  • Loading branch information
pionl committed Mar 12, 2020
1 parent 40cc31f commit 101a37f
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 6 deletions.
11 changes: 8 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
# Laravel eloquent model position
Position logic for Eloquent models with minimum setup. Before saving it will check if the position has changed
and updates the other entries based on the models position value.

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


Position logic for Eloquent models with minimum setup. Before saving it will check if the position has changed
and updates the other entries based on the models position value.


* [Installation](#installation)
* [Usage](#usage)
* [Migration example](#migration-example)
Expand All @@ -20,6 +23,8 @@ and updates the other entries based on the models position value.

## Installation

> Tested in Laravel 5.3 - 5.6, should work in all 5.* releases
**Install via composer**

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

Copyright (c) 2016 Martin Kluska
Copyright (c) 2016 Martin Kluska
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "pion/laravel-eloquent-position",
"description": "Position logic for Eloquent models with minimum setup",
"require": {
"laravel/framework": "5.1.* || 5.2.* || 5.3.* || 5.4.* || 5.5.* || 5.6.*"
"laravel/framework": "5.*"
},
"require-dev": {
"squizlabs/php_codesniffer": "2.*"
Expand Down
4 changes: 2 additions & 2 deletions src/PositionObserver.php
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ protected function forcedPosition($model, $position, $oldPosition = null)
$query = new PositionQuery($model, $position);

// Run the query
$query->runQuery($query, $oldPosition);
$this->runQuery($query, $oldPosition);
}

/**
Expand Down Expand Up @@ -123,7 +123,7 @@ protected function runQuery(AbstractPositionQuery $query, $oldPosition)
$eventResponse = $this->firePositioningEvent($query);

// Ignore updating the position and revert the position to original value
if ($eventResponse !== $eventResponse && $eventResponse === false) {
if ($eventResponse === false) {
// Update the new position to original position
$query->model()->setPosition($oldPosition);
} else {
Expand Down
2 changes: 2 additions & 0 deletions src/Query/PositionQuery.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

namespace Pion\Support\Eloquent\Position\Query;

use Illuminate\Database\Eloquent\Builder;
use Illuminate\Database\Eloquent\Model;
use Pion\Support\Eloquent\Position\Traits\PositionTrait;

Expand All @@ -27,6 +28,7 @@ class PositionQuery extends AbstractPositionQuery
* Creates the base query and builds the query
*
* @param Model|PositionTrait $model
* @param int $position
*/
public function __construct($model, $position)
{
Expand Down

0 comments on commit 101a37f

Please sign in to comment.