Laravel 5.2: Morph Map
A new undocumented feature in laravel 5.2 was introduced: The Morph Map for morphTo relations.
We all know the polymorphic relations, they are a type of relation to link multiple models with one common model. For instance if you have a User and a Blog Post model, both of these can have a "Picture" relationship.
From the documentation:
Polymorphic relations allow a model to belong to more than one other model on a single association. For example, imagine users of your application can "like" both posts and comments. Using polymorphic relationships, you can use a single likes table for both of these scenarios. Let's use the example from the documentation:
posts
id - integer
name - string
videos
id - integer
name - string
tags
id - integer
name - string
taggables
tag_id - integer
taggable_id - integer
taggable_type - string
You can see here, both videos and posts can have tags associated with them. In laravel 5.1 the contents of taggables table looked something like this:
Link: