用雄辩的ORM通过另一个表获取表记录

时间:2018-09-22 19:31:38

标签: php laravel eloquent laravel-5.7

我有三个表和两个数据透视表!

艺术家
* id(主要) ...

music_artists
* id(主要)
* music_id(foreignKey)
* artist_id(foreignKey)

音乐
id(主要)
...

专辑音乐
id(主要)
music_id(外键)
album_id(外键)
...

相册
id(主要)
...

我的问题是如何与laravel 口才的专辑的歌手联系?

1 个答案:

答案 0 :(得分:1)

在这种情况下没有本机关系。

我创建了<script> import componentNames from './component-names.json'; export default { watch: { xIs: { immediate: true, // run handler immediately on current `xIs` async handler(value) { try { const name = componentNames[value]; // 1. lookup real component name if (name) { Vue.component(name, () => import(`@/components/${name}`)); // 2. register component this.translatedName = name; // 3. set name for <component :is=""> } } catch (e) { console.warn(`cannot resolve component name: ${value}`, e); } } } } } </script> 关系,并支持HasManyThroughRepository on GitHub

安装后,您可以像这样使用它:

BelongsToMany