<?php namespace App\Models;

use Illuminate\Database\Eloquent\Model;


class Blog extends Model 
{

	protected $table = 'blog';

	public static function getSlug($title)
	{
	    $slug = str_slug($title);
		$slugCount = count( Blog::whereRaw("blogSlug REGEXP '^{$slug}(-[0-9]*)?$'")->get() );
		return ($slugCount > 0) ? "{$slug}-{$slugCount}" : $slug;
	}
}
