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()
{
$data = $this->modelClass::getDb()
->createCommand($this->queryBuilder())
->all();
$collect = new Collection($this);
$collect->setModel($this->modelClass);
$collect->setItems($data);
$collect = new Collection($this,
$this->modelClass::getDb()->createCommand($this->queryBuilder())->all()
, $this->modelClass
);
if ($this->asArray) {
return $collect->toArray();
}
+3 -1
View File
@@ -37,11 +37,13 @@ abstract class AbstractCollection extends Component implements \IteratorAggregat
*
* @param $query
* @param array $array
* @param null $model
*/
public function __construct($query, array $array = [])
public function __construct($query, array $array = [], $model = null)
{
$this->_item = $array;
$this->query = $query;
$this->model = $model;
parent::__construct([]);
}
+1 -1
View File
@@ -207,7 +207,7 @@ class Collection extends AbstractCollection
}
$_filters[] = $value;
}
return new Collection($this->query, $_filters);
return new Collection($this->query, $_filters, $this->model);
}
/**