Skip to content

Problem with method "with" + many via #12479

Closed
@alexpts

Description

@alexpts

What steps will reproduce the problem?

I want to get models with related models.

If "with" relation has operator 'via' with other relation with operator 'via' that yii2 set relation wrong.

All code:

$tableElements = EventAgendaElement::find()
            ->with(['allEventParticipant'])
            ->all();

 public function getAllEventParticipant()
    {
        return $this->hasMany(EventParticipant::class, ['Id' => 'EventParticipantId'])
            ->via('eventParticipantsInGroup');
    }

public function getEventParticipantsInGroup()
    {
        return $this->hasMany(EventParticipantInGroup::className(), ['EventAgendaParticipantGroupId' => 'Id'])
            ->via('eventAgendaParticipantGroup');
    }

public function getEventAgendaParticipantGroups()
    {
        return $this->hasMany(EventAgendaParticipantGroup::className(), ['AgendaElementId' => 'Id']);
    }

In populate method get all model EventParticipant but not set correct their to bucket.

Additional info

Q A
Yii version 2.0.8 and 2.0.9
PHP version 5.6
Operating system mac os

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions