Skip to content

Regression after PR #55471: Error when accessing nested attributes in manually set relations #55535

Closed
@tabuna

Description

@tabuna

Laravel Version

12.10.1

PHP Version

8.4

Database Driver & Version

No response

Description

After merging #55471, a regression was introduced in how manually set relations are handled via setRelations(). Behavior that previously returned null now results in a fatal error.

Attempts to address this in #55518 and #55519 do not fully restore the expected behavior.

Steps To Reproduce

$model = new class extends Model {};

$model->setRelations(['many' => ['one', 'two', 'three' => 84]]);

$result = $model->getAttribute('many.three');

✅ Expected behavior:

In versions prior to 12.10.1, this would return null.

❌ Actual behavior:

As of 12.10.1 (and with the mentioned PRs applied), the following error is thrown:

Error: Call to a member function relationLoaded() on null

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