This commit is contained in:
2023-04-01 21:04:28 +08:00
parent eac2800561
commit 0450226d36
2 changed files with 19 additions and 11 deletions
+11
View File
@@ -108,6 +108,17 @@ class ActiveQuery extends Component implements ISqlBuilder
'param' => $lists, 'param' => $lists,
]; ];
} }
/**
* @param bool $asArray
* @return static
*/
public function asArray(bool $asArray = true): static
{
$this->asArray = $asArray;
return $this;
}
/** /**
+8 -11
View File
@@ -34,18 +34,17 @@ abstract class HasBase implements \Database\Traits\Relation
* @var ModelInterface * @var ModelInterface
*/ */
protected mixed $model; protected mixed $model;
protected mixed $value = 0; protected mixed $value = 0;
/** /**
* HasBase constructor. * HasBase constructor.
* @param string $name * @param string $name
*/ */
public function __construct(public string $name) public function __construct(public string $name)
{ {
;
} }
/** /**
@@ -55,16 +54,14 @@ abstract class HasBase implements \Database\Traits\Relation
*/ */
public function __call($name, $arguments) public function __call($name, $arguments)
{ {
if (!method_exists($this, $name)) { if ($name !== 'get') {
$relation = Kiri::getDi()->get(Relation::class); return di(Relation::class)->getQuery($this->name)->$name(...$arguments);
$relation->getQuery($this->name)->$name(...$arguments);
} else { } else {
call_user_func([$this, $name], ...$arguments); return $this->get();
} }
return $this;
} }
/** /**
* @param $name * @param $name
* @return mixed * @return mixed