Iterating model collection

Is there a way to iterate through models collection using a closure? just like how laravel do it

Laravel Style


 $items = Model::where('column', $id)->get()->each(function($model)

        {

            $model->var = 0;  

            $model->save();  

        });



I’m not sure about closures usage but you can use each like this:




$items = Model::find()->where(['column' => $id]);

foreach ($items->each() as $model) {

    $model->var = 0;  

    $model->save();  

}