Skip to content

[Eloquent][Proposal] Morph relations with empty _type and _id #8499

Closed
@segadora

Description

@segadora

I am having problems with morph relations one-to-one, because of _type and _id can sometimes be null.

The looks like this.

subscription_type subscription_id
Creditcard 1
Creditcard 2
(null) (null)
Creditcard 2

When morphTo calls the (null) // (null) relation the script crashes because of a sql error.

SQLSTATE[42S22]: Column not found: 1054 Unknown column 'invoices.' in 'where clause' (SQL: select * from `invoices` where `invoices`.`` is null limit 1)

I want to be able to define in morphTo, that if subscription_type and subscription_id is null then return null or a new model.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions