Airship\Cabin\Hull\Blueprint\Blog::getTags PHP Method

getTags() public method

Get $num of the most popular tags, paginated to start at $offset
public getTags ( integer $num = 10, integer $offset ) : array
$num integer
$offset integer
return array
    public function getTags(int $num = 10, int $offset = 0) : array
    {
        $tags = $this->db->run('SELECT
                t.tagid,
                t.name,
                t.slug,
                COUNT(j.postid) AS num_posts
            FROM
                hull_blog_tags t
            LEFT JOIN
                hull_blog_post_tags j
                ON j.tagid = t.tagid
            JOIN
                hull_blog_posts p
                ON j.postid = p.postid
            WHERE
                p.status
                AND p.published <= current_timestamp
            GROUP BY
                t.tagid,
                t.name,
                t.slug
            ORDER BY COUNT(j.postid) DESC, t.name ASC
            OFFSET ' . $offset . '
            LIMIT ' . $num);
        if (empty($tags)) {
            return [];
        }
        return $tags;
    }