This commit is contained in:
2023-04-10 17:45:29 +08:00
parent b069bc425b
commit ecfe15c3ac
4 changed files with 5 additions and 5 deletions
+1 -1
View File
@@ -21,7 +21,7 @@ class HasCount extends HasBase
public function get(): array|ModelInterface|null
{
$relation = Kiri::getDi()->get(Relation::class);
return $relation->getQuery($this->name)->count();
return $relation->get($this->name);
}
}
+1 -1
View File
@@ -29,6 +29,6 @@ class HasMany extends HasBase
public function get(): array|Collection|null
{
$relation = Kiri::getDi()->get(Relation::class);
return $relation->getQuery($this->name)->get();
return $relation->get($this->name);
}
}
+1 -1
View File
@@ -28,6 +28,6 @@ class HasOne extends HasBase
public function get(): array|ModelInterface|null
{
$relation = Kiri::getDi()->get(Relation::class);
return $relation->getQuery($this->name)->first();
return $relation->first($this->name);
}
}
+2 -2
View File
@@ -4,6 +4,7 @@ declare(strict_types=1);
namespace Database;
use Exception;
use Kiri\Abstracts\Component;
use Kiri\Di\Context;
@@ -14,8 +15,6 @@ use Kiri\Di\Context;
class Relation extends Component
{
private array $_relations = [];
/** @var ActiveQuery[] $_query */
private array $_query = [];
@@ -52,6 +51,7 @@ class Relation extends Component
/**
* @param string $_identification
* @return mixed
* @throws Exception
*/
public function first(string $_identification): mixed
{