-
Notifications
You must be signed in to change notification settings - Fork 52
Morph Maps
Mark Wales edited this page Feb 11, 2016
·
1 revision
By default polymorphic relations will store the Entity class as the type:
| id | imageable_id | imageable_type |
|---|---|---|
| 1 | 10 | App\Post |
| 2 | 14 | App\Avatar |
However, you might not want the DB data tied to your application structure. You can use the $manager->morphMap() method to use custom names in these columns:
$manager->morphMap([
"post" => App\Post::class,
"avatar" => App\Avatar::class,
]);| id | imageable_id | imageable_type |
|---|---|---|
| 1 | 10 | post |
| 2 | 14 | avatar |