ActiveDataProvider

$dataProvider = new ActiveDataProvider([

    'query' => $query ,


    'sort'=>[


        'defaultOrder'=>['Expiration_date'=> SORT_DESC],


    ],


]);

I’m trying to chose my own attribute i.e. ‘Expiration_date’ to be my default attribute for sorting. I donot know which query to add because $query is undefined. Please help.

If query is undefined, where does the code you posted come from?