laravel-nestedset icon indicating copy to clipboard operation
laravel-nestedset copied to clipboard

How can I customize parent_id column in migration & How to add another column with different _lft and _rgt

Open abhishekjain-itsme opened this issue 4 years ago • 0 comments

Hello

I tried with this package and this is really awesome. Actually, I tried this package for MLM Tree work, and it works fine.

Now I have two things when I was customizing this table before the First parent_id to get the proper tree. And the second one is income_parent_id, By using this I am printing another tree with 4X(another no.) dimension tree.

So the first tree is working fine, But I need the same thing with income_paraent_id. So how can I create another different column for another kind of tree?

Example:

NestedSet::columns($table);<- I create parent_id, _lft, _rgt columns and it works fine for me.

The same thing I need with another column in the same database as my requirement. So I need more columns like income_parent_id,_lft (for income_parent_id), _rgt (for income_parent_id)

How can I customize for two different things?

My existing code:

`Schema::create('users', function (Blueprint $table) { $table->id();

        NestedSet::columns($table);
        $table->foreign('parent_id')->references('id')->on('users')->onDelete('restrict');

        $table->unsignedBigInteger('income_parent_id')->nullable(); // i need the same thing here also like parent_id with custom column name
        $table->foreign('income_parent_id')->references('id')->on('users')->onDelete('restrict');

        $table->string('name');
        $table->string('email')->unique();
        $table->string('mobile', 10)->unique();
        $table->rememberToken();
        $table->timestamps();
    });`

abhishekjain-itsme avatar Apr 21 '21 17:04 abhishekjain-itsme