etrepat/Baum working with two tables

171 views Asked by At

I'm trying to use Baum with two tables but I am not able to implement. My intention is to have a table to store the category information as id, name, slug and status and normal Baum table with foreign key category_id. In cadegoria the registration'm trying to accomplish Tree :: create ([ 'name' => $ category-> name, 'category_id' => $ category-> category_id]); but it does not work. Someone has a tip?

Mmy model file is:

   namespace App;
use Illuminate\Database\Eloquent\Model;
use Baum\Node;

class Tree extends Node
{
    protected $table = 't_r_e_e_s';


    protected $parentColumn = 'id';

    protected $nameColumn = 'name';

    protected $parentId = 'parent_id';


    protected $leftColumn = 'lft';


    protected $rightColumn = 'rgt';


    protected $depthColumn = 'depth';

    protected $fk_category_id = 'category_id';


    protected $guarded = array('id', 'name', 'parent_id', 'lft', 'rgt', 'depth', 'category_id');



    public function category()
    {
        return $this->belongsToMany('App\Category', 'category_id');
    }
}

if I comment the protected attributes works.

0

There are 0 answers