staudenmeir / eloquent-has-many-deep

Laravel Eloquent HasManyThrough relationships with unlimited levels
MIT License
2.67k stars 157 forks source link

relation variable returns only first result #51

Closed no0by5 closed 4 years ago

no0by5 commented 4 years ago

I have Users, Meetings and MeetingMails. User has a relation with Meeting and Meeting has a relation with MeetingMail. I defined the relation like this:

public function meetingMails(): HasManyDeep {
    return $this->hasManyDeepFromRelations(
        $this->meetings(),
        (new Meeting())->meetingMails()
    );
}

When is use $user->meetingMails to get the MeetingMails I only get the first MeetingMail. When I use $user->meetingMails()->get() I get all MeetingMails as excpected. Shouldn't these two code snippets do the same?

staudenmeir commented 4 years ago

Yes, they should. Can you please log the executed queries in both cases?

no0by5 commented 4 years ago

I can't reproduce this bug.... I don't know why it didn't work yesterday, but it works as expected now. Thanks for the quick answer.