honey-comb/slugs

HoneyComb slugs

0.2.2 2018-07-24 19:30 UTC

This package is auto-updated.

Last update: 2024-11-08 22:34:07 UTC


README

https://github.com/honey-comb/slugs

Description

Slugs manager for HoneyComb CMS

Attention

This is part core package HoneyComb CMS package.

If you want to use laravel version 5.5.* use slug package version 0.1.*

Requirement

  • php: ^7.1
  • laravel: ^5.6
  • composer

Installation

Begin by installing this package through Composer.

	{
	    "require": {
	        "honey-comb/slugs": "0.2.*"
	    }
	}

or

    composer require honey-comb/slugs

Usage

generateHCSlug(string $path, string $string, string $separator = '-')

It is a helper function, which requires few parameters:

$path - Under which domain the slug will be generated.

$string - Source from which text the slug will be generated.

$separator - You can specify a custom separator

Examples

Let's say we have 2 services House and Flat. Each of them will have a record with at title One. And both of them will require a slug.

$houseSlug = generateHCSlug('house', 'One'); // output: one

$flatSlug = generateHCSlug('flat', 'One'); // output: one

Only when we will call it with the same name few times, then it will kick in.

$flatSlug = generateHCSlug('flat', 'One'); // output: one

$flatSlug = generateHCSlug('flat', 'One'); // output: one-1

$flatSlug = generateHCSlug('flat', 'One'); // output: one-2