Stillat / relationships

Provides automated bi-directional @statamic entry relationships
MIT License
18 stars 1 forks source link

Q: Multiple collections related to multiple other collections #8

Closed jacksleight closed 1 year ago

jacksleight commented 2 years ago

Hey John, thanks for this awesome addon, I think it's exactly what I need, I just can't quite figure out the right way to configure it for my situation. Hope you might be able to give me some advise.

I'm working on a site that has five collections, and any of the entries in these collections could be related to any of the entries in any of the other collections. All the blueprints have the same related entries field:

handle: related
field:
  mode: default
  create: false
  collections:
    - events
    - clubs
    - businesses
    - services
    - articles
  display: Related
  type: entries
  icon: entries
  listable: hidden
  instructions_position: above
  read_only: false

What I'd like to happen is that when you add an entry to one of these fields the inverse relationship is also created.

As a start I tried to just add one relationship:

Relate::manyToMany(
    'articles.related',
    'services.related'
);

But I get an error when I run relate:fill.

Not sure if I'm setting up the relationship wrong, or I need to configure my fields differently, or if this kind of relationship just isn't possible? Thanks!

JohnathonKoster commented 2 years ago

HI there!

That type of relationship is not supported at the moment, but would be nice to have. I'll convert this to a feature request and take a look at this sometime soon :)

jacksleight commented 2 years ago

Amazing, thanks!

jacksleight commented 2 years ago

Hey John, thanks again for considering this. Just wanted to say that for now I can simply query the related field to find the inverse relationships when rending the template. They're not visible in the CP, but this is a perfectly acceptable workaround for me for now.