analogueorm / analogue

Analogue ORM : Data Mapper ORM for Laravel/PHP
MIT License
634 stars 51 forks source link

Automatically eager load not working #270

Open defektrain opened 6 years ago

defektrain commented 6 years ago

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 commented 6 years ago

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 ?