Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Automatically eager load not working #270

Open
defektrain opened this issue Jun 1, 2018 · 1 comment
Open

Automatically eager load not working #270

defektrain opened this issue Jun 1, 2018 · 1 comment

Comments

@defektrain
Copy link

Hello,
just trying to use eager load:
Mapper:

class RoleMap extends EntityMap
{
    public $timestamps = true;
    protected $with = ['roleStrings'];

    public function roleStrings(Role $role)
    {
        return $this->hasMany($role, RoleString::class);
    }
} 

If I trying this:

return mapper(Role::class)->find($id);

Relations not loading automatically.

But if I trying this:

return mapper(Role::class)->with(['roleStrings'])->find($id);

OR

return mapper(Role::class, RoleMap::class)->find($id);

All relations was loaded well.

So I'm just want to know there a bug or I doing something wrong?

@RemiCollin
Copy link
Member

I made a refactoring of the hydration process but auto eager loading seems to work fine in my test. Can you show me what the dump of return mapper(Role::class)->find($id); contains ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants