最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

php - Laravel many to many relation between TWO polymorphic types - Stack Overflow

programmeradmin5浏览0评论

I want to create a relationship between parents (which can be Mother or Father models) and their children (Son and Daughter models). For exemple purposes, they are defined like this:

father:
  id
  name

mother:
  id
  name

son:
  id
  name

daughter:
  id
  name

I created a pivot table parent_child:

parent_child:
  parent_id
  child_id
  parent_type
  child_type

How can I create the laravel relations? Most polymorphic relations I can find in the doc only work when one of the two sides of the relation is polymorphic, not both.

发布评论

评论列表(0)

  1. 暂无评论