In Yii2 in the dataProvider to specify a selection condition?

I create a gridView based on array:
GridView::widget([
 'dataProvider' => new ArrayDataProvider([
 'allModels' => $user['friends']['items'],
 'sort' => [
 'attributes' => ['id', 'username', 'email'],
]
]),
 'columns' => [
 ...

And I need to choose only such $user['friends']['items'], where the condition
isset($user['friends']['items']['set_phone']);

How to do it?
July 8th 19 at 16:12
2 answers
July 8th 19 at 16:14
Solution
The DataProvider is not responsible for the selection condition, You need to filter the array before it is passed to the DataProvider, for example, using array_filter
array_filter is what you need. Thank you:) - jessy38 commented on July 8th 19 at 16:17
July 8th 19 at 16:16
It is not necessary to use array_filter on the DataProvider!

Open the documentation, everything is written
nix-tips.ru/yii2-razbiraemsya-s-gridview.html

If in the example, use searchModel!

<?= GridView::widget([
 'dataProvider' =--> $dataProvider,
 'filterModel' => $searchModel,
 'rowOptions'=>function ($model, $key, $index, $grid){
$class=$index%2?'odd':'even';
 return [
'key'=>$key,
'index'=>$index,
'class'=>$class
];
},
]); ?>

Find more questions by tags PHPYii