【问题标题】:Laravel Eloquent: multiple nested relationships with 3 level deepLaravel Eloquent:具有 3 级深度的多个嵌套关系
【发布时间】:2020-08-01 17:35:02
【问题描述】:

我有 3 层深表:

1.plan -> 2.steps -> 3.nomenclature

而且我不需要具有 2 个不同嵌套表的加载对象命名法

3.1 - uom (1:1)
3.2. - ingredients (1 to many)

我现在使用 hasManyThrough 来接收命名对象。我可以为这个对象添加 3.1 uom:

$plan = Plan::with(['steps', 'items.nomenclature.uom'])

但我怎样才能添加 3.1 uom3.2。成分同时到命名对象?

【问题讨论】:

    标签: laravel eloquent nested relationship


    【解决方案1】:

    解决了。在项目模型中,我们需要添加到关系中

    with(['nomenclature', 'uom'])
    

    【讨论】:

      猜你喜欢
      • 2020-03-12
      • 1970-01-01
      • 2021-10-02
      • 2018-10-08
      • 2015-04-26
      • 2016-05-31
      • 1970-01-01
      • 2019-01-30
      • 1970-01-01
      相关资源
      最近更新 更多