Airship\Cabin\Bridge\Blueprint\Blog::makeBlogPostSlug PHP Method

makeBlogPostSlug() protected method

Make a generic slug for most tables
protected makeBlogPostSlug ( string $title, string $year = '', string $month = '' ) : string
$title string What are we basing the URL off of?
$year string
$month string
return string
    protected function makeBlogPostSlug(string $title, string $year = '', string $month = '') : string
    {
        if (empty($year)) {
            $year = \date('Y');
        }
        if (empty($month)) {
            $month = \date('m');
        }
        $query = 'SELECT count(*) FROM view_hull_blog_list WHERE blogmonth = ? AND blogyear = ? AND slug = ?';
        $slug = $base_slug = \Airship\slugFromTitle($title);
        $i = 1;
        while ($this->db->exists($query, $month, $year, $slug)) {
            $slug = $base_slug . '-' . ++$i;
        }
        return $slug;
    }