public function all($db = null) { if ($this->asArray) { return parent::all($db); } $result = $this->createCommand($db)->search(); if (empty($result['results'])) { return []; } $models = $this->createModels($result['results']); if (!empty($this->with)) { $this->findWith($this->with, $models); } foreach ($models as $model) { $model->afterFind(); } return $models; }