I have created a Json action in a controller which returns calendar entries and works fine. However, I would only like to return some of the fields from the model and not all of them. This works fine with ->select() if I only want to select certain database fields but I need to include some computed fields and so I cannot call select() with these.
This is maybe a Yii question but possibly just a PHP question, is there a simple way to map an array of Calendar to an array of a DTO with only some of the properties of calendar?
public function actionData($start, $end)
{
$query = Calendar::find();
$query->FilterWhere(['>=', 'startTimestamp', date("U",strtotime($start))])
->andFilterWhere(['<=', 'endTimestamp', date("U",strtotime($end))]);
return $query->all();
}