'plugins' => [
'fontcolor',
'video',
]
public static function getProviderByTotalQuestionTime($entity='m_news')
{
$mainTable = self::tableName();
$sql = "
SELECT {$mainTable}.id, {$mainTable}.name, COUNT({$entity}.id) AS total_count
FROM {$mainTable}
LEFT JOIN {$entity}
ON {$mainTable}.id = {$entity}.department_id
GROUP BY {$mainTable}.id
ORDER BY total_count DESC
";
$dataProvider = new SqlDataProvider([
'sql' => $sql,
'totalCount' => 5,
'pagination' => [
'pageSize' => 5,
],
]);;
return $dataProvider;
}
class DepartmentsSearch extends Model
{
public $id;
public $exist;
public $type;
public $name;
public function rules()
{
return [
[['id', 'type', 'exist'], 'integer'],
[['link', 'name','category_id'], 'safe'],
];
}
public function scenarios()
{
return Model::scenarios();
}
public function search($params)
{
$query = Departments::findPublishedWithAbolition();
$dataProvider = new ActiveDataProvider([
'query' => $query,
]);
$this->load($params);
if (!$this->validate()) {
return $dataProvider;
}
$query->andFilterWhere([
'id' => $this->id,
'type' => $this->type,
//'category_id' => $this->category_id,
'exist' => $this->exist,
]);
$query
->andFilterWhere(['like', 'LOWER(name)', mb_strtolower($this->name)])
;
return $dataProvider;
}
}