S
S
shik02021-09-16 18:31:15
PHP
shik0, 2021-09-16 18:31:15

How to set indexing of linked data in yii2?

Welcome all. Can you please tell me what should be done to set up indexing of linked data in yii2?
Let me explain what I mean: the ActiveRecord model has a method:

...
public function getProperties()
{
    return $this->hasMany(Property::class, ['entity_id' => 'id']);
}
...

And it is necessary that the output array be indexed by the slug field from the Property model. For some reason, the indexBy method simply substitutes the field name in the selection result and, accordingly, only one record remains.

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question