Yii Active Record如何为DataProvider中的每个模型安装场景

Yii Active Record how to install scenario for each models in DataProvider ?

public function searchView()
            {
                $criteria = new CDbCriteria([
                    'select' => 'last_comment,name,data,cdate,mdate,edate,coperator,eoperator',
                    'with' => ['houses', 'houses.city', 'houses.district', 'houses.street','stages']
                ]);
               $model = $this;
               //$model->scenario = 'searchView'; this is for dataprovider
                return new CActiveDataProvider($model , [
                    'criteria' => $criteria,
                    'sort' => [
                        'defaultOrder' => 'cdate DESC'
                    ],
                    'pagination' => $this->searchFrom || $this->searchTo || $this->district_key || $this->city_key ? false : ['pageSize' => 100]
                ])

;
                }

You can always loop through data property of CActiveDataProvider. Data is a simple array of models

first you need to store it in variable:

$dataProvider = new CActiveDataProvider($model , [
                    'criteria' => $criteria,
                    'sort' => [
                        'defaultOrder' => 'cdate DESC'
                    ],
                    'pagination' => $this->searchFrom || $this->searchTo || $this->district_key         || $this->city_key ? false : ['pageSize' => 100]
                    ]);

than you can loop through models:

foreach($dataProvider->data as $model){
    $model->scenario = 'searchView';
}

than you can return your data provider with scenario on each model

return $dataProvider;

i hope thats what you needed