我叫做 eid 好像不好使啊。
是用在 product 和 tag 这两个实体之间。
这是定义在 product 模型上的
public function tags()
{
return $this->morphToMany(Tag::class, 'taggable');
}
相关表结构
products
eid (主键)
...
tagables
id (主键,递增)
tag_id
taggable_type
taggable_id
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号
不是的 可以自定义 你仔细看看官方的文档 当前表的主键可以设置 外键也可以设置 你上面写的方法能传3个参数