Answer the question
In order to leave comments, you need to log in
How to use ArrayHelper with hasMany binding?
there is a connection
/**
* @return \yii\db\ActiveQuery
*/
public function getUserTacks()
{
return $this->hasMany(UserTack::class, ['user_id' => 'id']);
}
/**
* @return \yii\db\ActiveQuery
*/
public function getTacks()
{
return $this->hasMany(Tack::class, ['id' => 'tack_id'])->viaTable('user_tack', ['user_id' => 'id']);
}
Answer the question
In order to leave comments, you need to log in
ArrayHalper is made (hasMany) as and just for working with arrays of models, how did you use it with hasOne (one object) before?
In general, here is the guide: https://www.yiiframework.com/doc/guide/2.0/en/help...
And I advise you to get into the helper code, there is foreach at every step. So don't avoid it. Using a helper is a convenience and code reduction, but not critical if you don't use it somewhere.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question