Skip to content

Illuminate\Database\Eloquent\Relations\Relation::morphMap should allow numeric types #12845

@christian-ehmig

Description

@christian-ehmig

Currently, custom polymorphic types can be specified by either an array of morph classes or by specifying a map of type strings to classes (https://laravel.com/docs/5.2/eloquent-relationships#polymorphic-relations). However, it is not possible to use numeric keys as type "strings".

Given the following array
Relation::morphMap([ "1" => \App\Models\ModelOne::class, "2" => \App\Models\ModelTwo::class, ]);
The resulting morphMap is:
array:2 [ 0 => "App\Models\ModelOne" 1 => "App\Models\ModelTwo" ]

It should be possible to specify numeric ids which is common in database environments and also less storage hungry in terms of INT vs. VARCHARS.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions