How to use ArrayHelper in susesi hasMany?


Warning: count(): Parameter must be an array or an object that implements Countable in /home/styllloz/public_html/qa-theme/donut-theme/qa-donut-layer.php on line 274
0 like 0 dislike
25 views
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']); }

Question is it possible to obtain certain properties, for example name of model Tack by working ArrayHelper ? or just foreach
by | 25 views

2 Answers

0 like 0 dislike
foundArrayHelper::getColumn($user->tacks,'name')
by
0 like 0 dislike
ArrayHalper as for working with arrays and made models (hasMany), here is how You to this with hasOne(one object) used?
Actually here is the guide: https://www.yiiframework.com/doc/guide/2.0/en/help...

And suggest to get into the code of the helper, there is a foreach on each step. So it is not necessary to avoid it. The use of helper - convenience and reduction in code, but not critical, if You don't use it.
by

Related questions

0 like 0 dislike
2 answers
asked Apr 12, 2019 by Sergalas
0 like 0 dislike
2 answers
0 like 0 dislike
1 answer
0 like 0 dislike
1 answer
asked Apr 24, 2019 by maksim92
110,608 questions
257,186 answers
0 comments
35,573 users