Skip to content

Model::preventLazyLoading doesn't do anything  #48722

Description

@sektormediaofficial

Laravel Version

10.28.0

PHP Version

sail latest

Database Driver & Version

sail latest

Description

public function boot(): void
{
Model::preventLazyLoading(true);
}

Turning this setting on doesn't do anything. The model is still "lazy loaded". Please fix it

Steps To Reproduce

Add Model::preventLazyLoading(true)

Try to lazy load anything and it won't throw the exception:

> Model::preventLazyLoading(true)
> Message::find(34)->sender
[!] Aliasing 'Message' to 'App\Models\Message' for this Tinker session.
= App\Models\User {#7749
    id: 25,
    ...

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