analogue icon indicating copy to clipboard operation
analogue copied to clipboard

Automatically eager load not working

Open defektrain opened this issue 6 years ago • 1 comments

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?

defektrain avatar Jun 01 '18 18:06 defektrain

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 ?

RemiCollin avatar Jun 04 '18 08:06 RemiCollin