0

What is the best/standard way to create a relationship you can add to multiple dataobjects? using a DataExtension you can create a has_many like so

public static $has_many = array('Links' => 'Link');

but then in the mirrored has_one relation in Link you would have to explicitly list the classes using the DataExtension.

drawde83
  • 129
  • 2
  • 13

2 Answers2

1

Use a many_many instead of as has_many.

  • But then the has_one on Link would become $belongs_many_many so that wouldn't fix the problem. – drawde83 Aug 11 '14 at 05:34
  • Do you need the reverse relationship though? In most cases like these you don't, so you don't need to provide the `belongs_many_many`. –  Aug 11 '14 at 07:46
0

Have a look at the File and Image classes to get an idea of how the framework does this. The framework's unit tests for those classes will also provide an indication for how they are set up and used.

cryptopay
  • 1,084
  • 6
  • 7