Здравствуйте.
Имеется файл index.php:
<?= GridView::widget([
'dataProvider' => $dataProvider,
'columns' => [
[
'attribute' => 'title',
'value' => 'viewLink',
'format' => 'raw'
],
[
'attribute' => 'shortText',
'value' => 'shortText',
],
],
]); ?>
На странице с помощью этого кода выводятся записи из базы данных. Также на этой странице с помощью панели yii показывает в разделе Request следующее:
Route 'admin/education/index'
Action 'app\\modules\\admin\\controllers\\EducationController::actionIndex()'
Соответственно описываю actionIndex(
):
public function actionIndex()
{
$searchModel = new EducationSearch();
$dataProvider = $searchModel->search(Yii::$app->request->queryParams);
return $this->render('index', [
'searchModel' => $searchModel,
'dataProvider' => $dataProvider,
]);
}
Затем описываю EducationSearch()
:
class EducationSearch extends Education
{
/**
* @inheritdoc
*/
public function rules()
{
return [
[['id'], 'integer'],
[['id_sort'], 'integer'],
[['video_obychenie'], 'integer'],
[['title', 'text', 'video_path'], 'safe'],
];
}
/**
* @inheritdoc
*/
public function scenarios()
{
// bypass scenarios() implementation in the parent class
return Model::scenarios();
}
/**
* Creates data provider instance with search query applied
*
* @param array $params
*
* @return ActiveDataProvider
*/
public function search($params)
{
$query = Education::find();
$query->orderBy(['id_sort' => SORT_ASC]);
$query->andFilterWhere(['video_obychenie' => '2']);
// add conditions that should always apply here
$dataProvider = new ActiveDataProvider([
'query' => $query,
]);
$this->load($params);
if (!$this->validate()) {
// uncomment the following line if you do not want to return any records when validation fails
// $query->where('0=1');
return $dataProvider;
}
// grid filtering conditions
$query->andFilterWhere([
'id' => $this->id,
]);
$query->andFilterWhere(['like', 'title', $this->title])
->andFilterWhere(['like', 'text', $this->text])
->andFilterWhere(['like', 'video_path', $this->video_path]);
return $dataProvider;
}
}
То есть сейчас выводится данные, где $query->andFilterWhere(['video_obychenie' => '2']);
, т.е. video_obychenie=2. И отображается все эти записи с помощью первого кода, который указал выше <?= GridView::widget(['dataProvider' => $dataProvider,....
Подскажите, пожалуйста, а как можно на той же странице вывести отдельным блоком записи у которых уже будет video_obychenie=3, т.е. $query->andFilterWhere(['video_obychenie' => '3']);
Буду очень благодарен за вашу помощь:)