Dataprovider - filter and count items - yii framework

Hello,

can anyone tell me, how I can filter my dataprovider?

I have an dataprovider object with round about 1000 items with attributes like name, startdate, enddate, status, … There could be some entries for one name. I want to count the items to one name, get the average of startdate - enddate (of all items) and want to display it in a gridview like:

name | average time | count

But I don’t know how I can filter my dataprovider. Thanks in advance!

Could you show us the involved models (and db tables)?

docs are pretty comprehensive please take look at the following section of active record guides

https://www.yiiframework.com/doc/guide/2.0/en/output-data-providers#active-data-provider

1 Like