tfdirq
Last Updated: October 07, 2016
·
389
· karataserkan

Yii2 Multi DataProvider

add
"karataserkan/yii2-multi-dataprovider": "*"
to the require section of your composer.json file.

use karataserkan\yii2MultiDataProvider\MultiDataProvider;

$data1 = new ActiveDataProvider([
    'query' => $query,
]);

$data2 = new ArrayDataProvider([
    'allModels' => [...],
]);

$dataProvider = new MultiDataProvider([
    'dataProviders' => [$data1,$data2],
]);