etrepat / baum

Baum is an implementation of the Nested Set pattern for Laravel's Eloquent ORM.
http://etrepat.com/baum
MIT License
2.24k stars 460 forks source link

Not working with laravel 5.8 #310

Open alfredkoncsag opened 5 years ago

alfredkoncsag commented 5 years ago

This package not working with laravel 5.8, or do you have new release for laravel 5.8 version?

 /vendor/baum/baum/src/Baum/Move.php:357

    355|     $method = $halt ? 'until' : 'fire';
    356| 
  > 357|     return static::$dispatcher->$method($event, $this->node);

Laravel Upgrade Guide 5.8: The fire Method Likelihood Of Impact: Low

The fire method (which was deprecated in Laravel 5.4) of the Illuminate\Events\Dispatcher class has been removed. You should use the dispatch method instead.

mkwsra commented 5 years ago

Just use the new version "baum/baum": "2.x",

it's mentioned here as well

karigarweb commented 5 years ago

It just throws another error:

SQLSTATE[42S22]: Column not found: 1054 Unknown column 'right' in 'order clause' (SQL: select * from types order by right desc limit 1 lock in share mode)

Although my model is configured correctly with following code:

`class Type extends Node implements HasMedia {

use HasMediaTrait, VueTableSearch;
/**
 * Table name.
 *
 * @var string
 */
protected $table = 'types';

protected $searchAble = [
    'name', 'slug',
];

protected $fillable = ['name','slug','status','lat','lng','parent_id', 'order_id'];

protected $filterJoins = ['parent' => ['name']];

 protected $parentColumn = 'parent_id';
 protected $leftColumn = 'lft';
 protected $rightColumn = 'rgt';
 protected $depthColumn = 'depth';
 protected $orderColumn = 'rgt';
 protected $guarded = array('id', 'parent_id', 'lft', 'rgt', 'depth');`
mkwsra commented 5 years ago

@karigarweb since version 2, not sure which tag specifically but you have to do it this way:

/**
 * Get the "default" left column name.
 *
 * @return string
 */
public function getDefaultLeftColumnName()
{
    return 'lft';
}

/**
 * Get the "default" right column name.
 *
 * @return string
 */
public function getDefaultRightColumnName()
{
    return 'rgt';
}

And for sure there is no need for the protected attributes

karigarweb commented 5 years ago

Thanks @mkwsra, this fixed the issue.

mkwsra commented 5 years ago

And you may use properties if you would like:

    $leftColumnName = 'lft';
    $rightColumnName = 'rgt';
shinnlu commented 4 years ago

thanks @mkwsra , it's really help to solve problem from 5.8