SilverStripe无法填充多个成员子女

发布于 2025-01-22 08:28:43 字数 626 浏览 3 评论 0原文

我有3种用户 推销员=>有很多买家 买家=>有很多代理 代理人没有孩子

,所以我想在查看推销员时列出所有与该推销员交往的买家 所有代理商以

class MemberExtension extends DataExtension
{
    private static $has_one = [
      'RefSalesman'    => Member::class,
      'AgentOwner'     => Member::class,
    ];

    private static $has_many = [
        'Buyers'                 => Member::class,
        'Agents'                 => Member::class,
    ];

    private static $summary_fields = [
      'RefSalesman.Name'    => 'Ref Salesman',
      'AgentOwner.Name'    => 'Agent Owner',
    ];

这种方式查看买家时,我只能看到买家下市的代理商,但在查看推销员时没有买家。

I have 3 type of users
salesman => has many buyers
buyer => has many agents
agent has none child

so I want to list all the buyers associate with that salesman when viewing salesman
and all the agents when viewing buyer in admin

class MemberExtension extends DataExtension
{
    private static $has_one = [
      'RefSalesman'    => Member::class,
      'AgentOwner'     => Member::class,
    ];

    private static $has_many = [
        'Buyers'                 => Member::class,
        'Agents'                 => Member::class,
    ];

    private static $summary_fields = [
      'RefSalesman.Name'    => 'Ref Salesman',
      'AgentOwner.Name'    => 'Agent Owner',
    ];

This way I am only able to see agents listing under buyers but no buyers when viewing salesman.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

記柔刀 2025-01-29 08:28:43

这些许多人的关系不知道他们指的是哪一个。作为同一类,您必须明确指定点表示的目标关系:有关详细信息,请参见Has-Many文档。

private static $has_many = [
    'Buyers'                 => Member::class.'.RefSalesman',
    'Agents'                 => Member::class.'.AgentOwner',
];

These has-many relations do not know to which has-one they are referring to. Being both the same class, you must explicitely specify the destination relation in dot notation: see the has-many documentation for details.

private static $has_many = [
    'Buyers'                 => Member::class.'.RefSalesman',
    'Agents'                 => Member::class.'.AgentOwner',
];
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文