Skip to content

[5.1] [5.2] Polymorphic relation naming is inconsistent #10501

@joostbaptist

Description

@joostbaptist

Hi,

Like #9427, I'm running into some strange naming behaviour with polymorphic relations. I would like to ask you to look at this again.

My polymorphic relation is defined as follows in class Module:

public function moduleInstance()
{
    return $this->morphTo();
}

Now, in order to load this relation, I have to call:

$module->load('moduleInstance');

However, to retrieve this relation, I have to call:

$module->module_instance

This clearly shows that naming is inconsistent. All relations are named using camel case and it seems that only polymorphic relations are named using snake case.

Here is another example that clearly shows this inconsistent behaviour:

// moduleType is another, BelongsTo relation that is named using camel case
$module->load(['moduleInstance', 'moduleType']);
dd($module);

Below is a screenshot that shows the result of executing the above code:

screen shot 2015-10-06 at 11 51 12

Also note that another empty relation ('moduleInstance') is added using an actually consistent name.

Thanks in advance!

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions