コード例 #1
0
ファイル: School.php プロジェクト: IVsevolod/zouk
 public function getImgs()
 {
     return $this->hasMany(Img::className(), ['id' => 'entity_2_id'])->viaTable(EntityLink::tableName(), ['entity_1_id' => 'id'], function ($query) {
         /** @var ActiveQuery $query */
         $query->onCondition(['entity_1' => self::THIS_ENTITY, 'entity_2' => Img::THIS_ENTITY])->orderBy(['sort' => SORT_DESC]);
     });
 }