<?php 
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Support\Str;

class Gallery extends Model{
	protected $table = 'gallery';
	public static function getCategorySlug($title){
	    $slug = Str::slug($title);
		$slugCount = count(Gallery::whereRaw("gallerySlug REGEXP '^{$slug}(-[(0-9)]*)?$'")->get() );
		return ($slugCount > 0) ? "{$slug}-({$slugCount})" : $slug;
	}
}
