Why Yii Do Not Implement Polymorphic Relations ?

Hello every body,

At my work we use Laravel’s ORM (Eloquent) because it is stand-alone.

This ORM Follow ActiveRecord Pattern (like Yii’s CActiveRecord). Laravel implements polymorphic relations and it’s very usefull, why yii don’t implements it ?

More informations about polymorphic relations

IMO… you could define hasMany relations in yii which could achieve the same (could combine the via method for pivot) - have you faced any issues?

Have you read Many to many polymorphic relation (on laravel documentation) ? Yii does not allow this

Yes, if you need a similar reusable component - in yii you need to add a trait or behavior or extend AR. As I understand, in Laravel, this feature would need you to create a specific table design/structure and attribute naming conventions for the relations to work.

There is an open enhancement request of some AR behaviors being planned for implementation by yii team. You may want to check that, and create a new enhancement request separately.