How to define a composite field in connection Yii2?

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} ?
July 9th 19 at 13:15
1 answer
July 9th 19 at 13:17
/**
 * A function generating a string identifier of the company in the table Review
 * @return boolean
*/
 public function getReview_id()
{
 return 'company_id_'.$this->id;
}

/**
 * The function of obtaining the rating company
 * @return integer
*/
 public function getRating()
{
 return $this->hasMany(Reviews::className(), ['chan_channel' => 'review_id'])->average('star');
 }

Generally, if someone come in handy

Find more questions by tags MySQLYii