Files
kiri-core/Database/HasCount.php
T

37 lines
592 B
PHP
Raw Normal View History

2020-08-31 12:38:32 +08:00
<?php
2020-10-29 18:17:25 +08:00
declare(strict_types=1);
2020-08-31 12:38:32 +08:00
namespace Database;
use Exception;
/**
* Class HasCount
* @package Database
*/
class HasCount extends HasBase
{
/**
* @param $name
* @param $arguments
* @return $this
* @throws Exception
*/
2020-12-17 14:09:14 +08:00
public function __call($name, $arguments): static
2020-08-31 12:38:32 +08:00
{
$this->_relation->getQuery($this->model::className())->$name(...$arguments);
return $this;
}
/**
* @return array|null|ActiveRecord
* @throws Exception
*/
2020-12-17 14:09:14 +08:00
public function get(): array|ActiveRecord|null
2020-08-31 12:38:32 +08:00
{
return $this->_relation->count($this->model::className(), $this->value);
}
}