code: protected function serializeModels(array $models)
      {
          list($fields, $expand) = $this->getRequestedFields();
          foreach ($models as $i => $model) {
              if ($model instanceof Arrayable) {
                  $models[$i] = $model->toArray($fields, $expand);
              } elseif (is_array($model)) {
                  $models[$i] = ArrayHelper::toArray($model);
              }
          }
  
          return $models;
      }
docs: Serializes a set of models.
  @param array $models
  @return array the array representation of the models