变更
This commit is contained in:
+6
-9
@@ -160,10 +160,11 @@ class ActiveQuery extends Component implements ISqlBuilder
|
|||||||
public function first(): ModelInterface|null
|
public function first(): ModelInterface|null
|
||||||
{
|
{
|
||||||
$data = $this->execute($this->builder->one())->one();
|
$data = $this->execute($this->builder->one())->one();
|
||||||
if (empty($data)) {
|
if (!is_null($data)) {
|
||||||
return NULL;
|
return $this->populate($data);
|
||||||
|
} else {
|
||||||
|
return NULL;
|
||||||
}
|
}
|
||||||
return $this->populate($data);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -234,9 +235,8 @@ class ActiveQuery extends Component implements ISqlBuilder
|
|||||||
if (!($data = $this->execute($this->builder->all())->all())) {
|
if (!($data = $this->execute($this->builder->all())->all())) {
|
||||||
return new Collection($this, [], $this->modelClass);
|
return new Collection($this, [], $this->modelClass);
|
||||||
}
|
}
|
||||||
if (!empty($this->with)) {
|
|
||||||
$this->getWith($this->modelClass);
|
$this->getWith($this->modelClass);
|
||||||
}
|
|
||||||
$collect = new Collection($this, $data, $this->modelClass);
|
$collect = new Collection($this, $data, $this->modelClass);
|
||||||
if ($this->asArray) {
|
if ($this->asArray) {
|
||||||
return $collect->toArray();
|
return $collect->toArray();
|
||||||
@@ -261,9 +261,6 @@ class ActiveQuery extends Component implements ISqlBuilder
|
|||||||
*/
|
*/
|
||||||
public function getWith(ModelInterface $model): ModelInterface
|
public function getWith(ModelInterface $model): ModelInterface
|
||||||
{
|
{
|
||||||
if (empty($this->with)) {
|
|
||||||
return $model;
|
|
||||||
}
|
|
||||||
return $model->setWith($this->with);
|
return $model->setWith($this->with);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user