public function count(string $column = null): int
    {
        if (is_null($column)) {
            if (!empty($this->loader->primaryKey())) {
                //@tuneyourserver solves the issue with counting on queries with joins.
                $column = "DISTINCT({$this->loader->primaryKey()})";
            } else {
                $column = '*';
            }
        }

        return $this->compiledQuery()->count($column);
    }