public function getPages()
{
return $this
->hasMany(Page::className(), ['id_page' => 'id_page'])
->viaTable(TagJoinPage::tableName(), ['id_tag' => 'id_tag']);
}
public function getDataProvider()
{
return new ActiveDataProvider(['query' => self::find()->joinWith(['pages'])]);
}
public function getDataProvider()
{
return new SqlDataProvider([
'sql' => 'select `tag`.*, (select count(*) from `tag_join_page` where `tag_join_page`.`id_tag` = `tag`.`id_tag`) as `total` from `tag` order by `total` DESC',
'pagination' => [
'pageSize' => 50
]
]);
}