Jump to:

3448 Posts in 1062 Topics by 738 members

Data Model Questions

SilverStripe Forums » Data Model Questions » What relationship to choose?

Moderators: martimiz, Sean, biapar, Willr, Ingo, swaiba, simon_w

Page: 1
Go to End
Author Topic: 348 Views
  • Nobrainer Web
    Avatar
    Community Member
    134 Posts

    What relationship to choose? Link to this post

    Hi devs,

    I need a bit of guidance, i have a DealerHolder.php Page, that will hold DataObject Dealer.
    The Dealers should be added to one DealerHolder page, and then be available on translations of this page.
    What is the best way to achive this?

    Right now i have a many_many relation, and it kinda works, i just need to check each dealer on each translation.
    Is there som better / more correct way to achive what i'm looking for?

  • novaweb
    Avatar
    Community Member
    115 Posts

    Re: What relationship to choose? Link to this post

    I think you are wanting

    DealerHolder.php

    static $has_many("Dealers" => "Dealer");

    Dealer.php

    static $has_one("DealerHolder" => "DealerHolder");

  • Nobrainer Web
    Avatar
    Community Member
    134 Posts

    Re: What relationship to choose? Link to this post

    Hi Novaweb,

    But as i see it, that does require me to add new dataobjects for each translation, which is a lot of extra work and does gives problems keeping everything in sync.

    Is there something i'm not seeing?

    348 Views
Page: 1
Go to Top

Want to know more about the company that brought you SilverStripe? Then check out SilverStripe.com

Comments on this website? Please give feedback.