Skip to content
This repository was archived by the owner on Jul 16, 2023. It is now read-only.
This repository was archived by the owner on Jul 16, 2023. It is now read-only.

belongsTo doesn't find right foreingKey #285

Open
@lamalab

Description

@lamalab

If foreingKey is not specified belongsTo doesn't find the right function to determine it.
in version 3.0.0 this was the code:

$backtrace = debug_backtrace(false);
$caller = ($backtrace[1]['function'] == 'handleRelationalArray')? $backtrace[3] : $backtrace[1];
$relation = $caller['function'];

in the latest release (3.2.0) is:

if ($backtrace[1]['function'] == 'handleRelationalArray') {
    $relation = $backtrace[1]['args'][0];
} else {
    $relation = $backtrace[3]['function'];
}

As you can see, in 3.2.0 relase $backtrace[1] and backtrace[3] are inverted compared to the version 3.0.0 and this release works well.
Inverting $backtrace[1] with $backtrace[3] works well.
Thanks ENx

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