访问数据透视表“第三模型关系"在 Laravel 雄辩
问题描述
我有这种多对多关系 Laravel Eloquent 关系模型是:
I have this Many-to-Many relation Laravel Eloquent relationship The Models are:
我可以在控制器中做到这一点:
I am able to do this in the Controller:
在这里,我仅通过直接枢轴关系获取 email_subtype_id,但必须做额外的工作才能获取相关的电子邮件子类型名称.
Here I am getting the email_subtype_id only by direct pivot relation but have to do extra work to get the related email sub-type name.
我需要从第 3 个模型 EmailSubtype 关系 oneToMany [hasMany 和 belongsTo] 中获取电子邮件子类型名称 [Directly],该关系与使用 EmailSubtype 模型的 Pivot 模型相关,使用类似:
I need to get the email sub-type name [Directly] from the 3rd Model EmailSubtype relationship oneToMany [hasMany and belongsTo] that relates to Pivot model with EmailSubtype model using something like:
请帮忙!
推荐答案
使用这个:
这篇关于访问数据透视表“第三模型关系"在 Laravel 雄辩的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!