This commit is contained in:
2020-09-08 01:17:35 +08:00
parent 3680ab1dfb
commit 51b79ed1ea
3 changed files with 8 additions and 9 deletions
+4 -7
View File
@@ -218,13 +218,10 @@ class ActiveQuery extends Component
*/ */
public function all() public function all()
{ {
$data = $this->modelClass::getDb() $collect = new Collection($this,
->createCommand($this->queryBuilder()) $this->modelClass::getDb()->createCommand($this->queryBuilder())->all()
->all(); , $this->modelClass
);
$collect = new Collection($this);
$collect->setModel($this->modelClass);
$collect->setItems($data);
if ($this->asArray) { if ($this->asArray) {
return $collect->toArray(); return $collect->toArray();
} }
+3 -1
View File
@@ -37,11 +37,13 @@ abstract class AbstractCollection extends Component implements \IteratorAggregat
* *
* @param $query * @param $query
* @param array $array * @param array $array
* @param null $model
*/ */
public function __construct($query, array $array = []) public function __construct($query, array $array = [], $model = null)
{ {
$this->_item = $array; $this->_item = $array;
$this->query = $query; $this->query = $query;
$this->model = $model;
parent::__construct([]); parent::__construct([]);
} }
+1 -1
View File
@@ -207,7 +207,7 @@ class Collection extends AbstractCollection
} }
$_filters[] = $value; $_filters[] = $value;
} }
return new Collection($this->query, $_filters); return new Collection($this->query, $_filters, $this->model);
} }
/** /**