Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

1.0.x stable #211

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
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
10 changes: 10 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
## 1.0.15
_Mar 4 2015_
* bug fixes
- Backport minor bugfixes from master.

## 1.0.14
_Mar 3 2015_
* bug fixes
- Backwards compatible version for Laravel 4.2.x.

## 1.0.13
_Sep 30 2014_
* bug fixes
Expand Down
11 changes: 6 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@

[![Build Status](https://travis-ci.org/etrepat/baum.png?branch=master)](https://travis-ci.org/etrepat/baum)

Baum is an implementation of the [Nested Set](http://en.wikipedia.org/wiki/Nested_set_model)
pattern for [Laravel 4's](http://laravel.com/) Eloquent ORM.
Baum is an implementation of the [Nested Set](http://en.wikipedia.org/wiki/Nested_set_model) pattern for [Laravel 4's](http://laravel.com/) Eloquent ORM.

> For **Laravel 5.x compatibility**, check the [master](https://github.com/etrepat/baum/tree/master) branch or use the latest [1.1.x tagged release](https://github.com/etrepat/baum/releases).

## Documentation

Expand Down Expand Up @@ -93,7 +94,7 @@ ordinary trees are suddenly quite fast. Nifty, isn't it?
<a name="installation"></a>
## Installation

Baum works with Laravel 4 onwards. You can add it to your `composer.json` file
Baum works with Laravel 4.2 onwards. You can add it to your `composer.json` file
with:

"baum/baum": "~1.0"
Expand Down Expand Up @@ -331,7 +332,7 @@ You can ask some questions to your Baum nodes:
* `isAncestorOf($other)`: Returns true if node is an ancestor of the other.
* `isSelfOrAncestorOf($other)`: Returns true if node is self or an ancestor.
* `equals($node)`: current node instance equals the other.
* `insideSubtree($node)`: Checks wether the given node is inside the subtree
* `insideSubtree($node)`: Checks whether the given node is inside the subtree
defined by the left and right indices.
* `inSameScope($node)`: Returns true if the given node is in the same scope
as the current one. That is, if *every* column in the `scoped` property has
Expand Down Expand Up @@ -474,7 +475,7 @@ Retrieving a complete tree hierarchy into a regular `Collection` object with
its children *properly nested* is as simple as:

```php
$tree = Category::where('name', '=', Books)->first()->getDescendantsAndSelf()->toHierarchy();
$tree = Category::where('name', '=', 'Books')->first()->getDescendantsAndSelf()->toHierarchy();
```

<a name="node-model-events"></a>
Expand Down
8 changes: 4 additions & 4 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@
],
"require": {
"php": ">=5.3.0",
"illuminate/support": "4.*|5.*",
"illuminate/console": "4.*|5.*",
"illuminate/filesystem": "4.*|5.*",
"illuminate/database": "4.*|5.*"
"illuminate/support": "4.*",
"illuminate/console": "4.*",
"illuminate/filesystem": "4.*",
"illuminate/database": "4.*"
},
"require-dev": {
"phpunit/phpunit": "~4.0",
Expand Down
2 changes: 1 addition & 1 deletion src/Baum/BaumServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ class BaumServiceProvider extends ServiceProvider {
*
* @var string
*/
const VERSION = '1.0.13';
const VERSION = '1.0.15';

/**
* Indicates if loading of the provider is deferred.
Expand Down
3 changes: 2 additions & 1 deletion src/Baum/Node.php
Original file line number Diff line number Diff line change
Expand Up @@ -500,8 +500,9 @@ public function scopeWithoutRoot($query) {
public function scopeLimitDepth($query, $limit) {
$depth = $this->exists ? $this->getDepth() : $this->getLevel();
$max = $depth + $limit;
$scopes = array($depth, $max);

return $query->whereBetween($this->getDepthColumnName(), array($depth, $max));
return $query->whereBetween($this->getDepthColumnName(), array(min($scopes), max($scopes)));
}

/**
Expand Down
2 changes: 1 addition & 1 deletion src/Baum/SetValidator.php
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ protected function validateBounds() {
$qualifiedRgtCol >= parent.$rgtCol)))";

$query = $this->node->newQuery()
->join($connection->raw($grammar->wrap($tableName).' AS parent'),
->join($connection->raw($grammar->wrapTable($tableName).' AS parent'),
$parentColumn, '=', $connection->raw('parent.'.$grammar->wrap($primaryKeyName)),
'left outer')
->whereRaw($whereStm);
Expand Down
2 changes: 1 addition & 1 deletion tests/suite/QueryBuilderExtensionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public function testAggregatesRemoveOrderBy() {
$this->assertEquals(1, $results);

$builder = $this->getBuilder();
$builder->getConnection()->shouldReceive('select')->once()->with('select count(*) as aggregate from "users"', array())->andReturn(array(array('aggregate' => 1)));
$builder->getConnection()->shouldReceive('select')->once()->with('select count(*) as aggregate from "users" limit 1', array())->andReturn(array(array('aggregate' => 1)));
$builder->getProcessor()->shouldReceive('processSelect')->once()->andReturnUsing(function($builder, $results) { return $results; });
$results = $builder->from('users')->orderBy('age', 'desc')->exists();
$this->assertTrue($results);
Expand Down