Laravel 5.6 如何添加两列以上来处理多态关系

How to add more than two columns to handle a polymorphic relationship in Laravel 5.6

Laravel 中的默认多态关系由两列 id 和 type 处理。

eg. commendable_id,commentable_type

如果我想在评论中添加四列而不是两列怎么办 table。

commentable_id, commentable_type, commentedby_id(a user id),commentedby_type(a user type)

Laravel 是否允许我们添加四列?有没有办法实现这个概念。

提前致谢

解决方案是创建 2 个独立的多态关系,一个用于 commentable,一个用于 commentedby。

return $this->morphToMany(SomeClass::class, 'relation', 'relations_table')
->where('connection_type', '3_field')
->where('something', '4_field')