protected function countResource(string $resource, array $where = null)
    {
        $model = $this->resources[$resource]['model'];
        $database = $model::getDatabase();
        return $database->count($model::TABLE, $where ?? []);
    }