public function generateSlug($title, $tableName, $primaryKey, $languageSlug = '', $id = 0, $translatable = false,
        $hasVirtualSlug = false, $delimiter = "-"
    ) {
        $count = 0;
        $found = true;
        $originalSlug = str_slug($title, $delimiter);

        while($found){
            if($count != 0) {
                $slug = $originalSlug.$delimiter.$count;
            }else{
                $slug = $originalSlug;
            }

            $countObj = DB::table($tableName);
            if ($translatable) {
                if($hasVirtualSlug) {
                    $countObj->where('slug_'.$languageSlug, $slug);
                }else{
                    $countObj->where('slug->'.$languageSlug, $slug);
                }
            }else{
                $countObj->where('slug', $slug);
            }
            if($id) {
                $countObj->where($primaryKey, '!=', $id);
            }
            $countPosts = $countObj->count();

            if(!$countPosts) {
                return $slug;
            }
            $count++;
        }
        return $originalSlug;
    }