Good day,
The need arose to hasMany relationship using a composite field:
/**
* The function of obtaining the rating company
* @return integer
*/
public function getRating()
{
return $this->hasMany(Reviews::className(), ['chan_channel' => 'id'])->average('star');
}
The fact that the table Reviews, you can choose the records with company_id_{$company_id} in the chan_channel and record data to calculate AVG('star').
Ie record with company_id_1 belong to the company with id=1.
How to specify in the method hasMany composite field company_id_{$company_id} ?