Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

Hirotaka's avatar

Many models as Publisher Polymorphic Relationship with pivot ?

Hi I have problem with relation and database design. there are three tables 'articles' ,'users' , 'companies'

"articles" -id

"users" -id

"companies" -id

to simplify the case ,let's assume that 'article' table have just 'id' field same 'users' and 'companies' Now article have many publishers and publishers are user model or company model.

my pivot table must be something like that 'authors' -id, -model_id, -model_name, -article_id

is there any way to get ids article's publisher and get data from models in one collection with single query? maybe i misunderstanding the problem is there simpler solution for that case.

thx in advance

0 likes
0 replies

Please or to participate in this conversation.