diff --git a/ActiveQuery.php b/ActiveQuery.php index 1ca736e..ceb44d3 100644 --- a/ActiveQuery.php +++ b/ActiveQuery.php @@ -238,10 +238,8 @@ class ActiveQuery extends Component implements ISqlBuilder $this->getWith($this->modelClass); $collect = new Collection($this, $data, $this->modelClass); - if ($this->asArray) { - return $collect->toArray(); - } - return $collect; + + return $this->asArray ? $collect->toArray() : $collect; } /** diff --git a/Model.php b/Model.php index 25c7674..ef7896c 100644 --- a/Model.php +++ b/Model.php @@ -279,9 +279,6 @@ class Model extends Base\Model */ private function withRelates($relates): array { - if (!$this->hasWith()) { - return $relates; - } foreach ($this->getWith() as $val) { $relates[$val] = $this->withRelate($val); }