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

Adjacency list parent_id duplication messes up tree #59

Open
sts-ryan-holton opened this issue Feb 23, 2024 · 0 comments
Open

Adjacency list parent_id duplication messes up tree #59

sts-ryan-holton opened this issue Feb 23, 2024 · 0 comments

Comments

@sts-ryan-holton
Copy link

This is a bit of a longshot here, I'm using the laravel-adjacency-list package in my project. This package works by having a column on a model called parent_id, which when null denotes a root level item, then, models below it, loaded in via a children relationship may have an unlimited depth.

I have three models:

  • MarketingAutomation
  • MarketingAutomationAction
  • MarketingAutomationActionCondition

Based on these models, the MarketingAutomationAction is the model which contains the parent_id table and functionality around that package. In addition, this model also a foreign id column to marketing_automation_id.

MarketingAutomationActionCondition models are linked to actions. So in the end, we may end up with the following hierarchy:

  • Marketing automation
    • Marketing automation action
      • Marketing automation action condition
      • Marketing automation action condition
    • Marketing automation action
      • Marketing automation action
        • Marketing automation action condition
      • Marketing automation action
        • Marketing automation action
    • Marketing automation action

I've put \Bkwld\Cloner\Cloneable on all three of these models, then, I've added the following to each:

MarketingAutomation

protected $cloneable_relations = ['actions'];

MarketingAutomationAction

protected $cloneable_relations = ['children', 'conditions'];

When I attempt to clone an automation using MarketingAutomation::find(1)->duplicate(), the table structure of the. MarketingAutomationAction gets completely messed up, the parent_id column doesn't know how to relate to another model etc.

Any way to resolve this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant