PHPackages                             mgboateng/eloquent-slug - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Database &amp; ORM](/categories/database)
4. /
5. mgboateng/eloquent-slug

ActiveLibrary[Database &amp; ORM](/categories/database)

mgboateng/eloquent-slug
=======================

Create elegant slugs in Laravel models with ease

v0.2.0(9y ago)3333[1 issues](https://github.com/mgboateng/eloquent-slug/issues)MITPHPPHP &gt;=5.6

Since Jun 28Pushed 8y agoCompare

[ Source](https://github.com/mgboateng/eloquent-slug)[ Packagist](https://packagist.org/packages/mgboateng/eloquent-slug)[ RSS](/packages/mgboateng-eloquent-slug/feed)WikiDiscussions master Synced 4w ago

READMEChangelog (2)Dependencies (5)Versions (3)Used By (0)

Generate elegant slugs when saving Laravel Eloquent Models
==========================================================

[](#generate-elegant-slugs-when-saving-laravel-eloquent-models)

[![Build Status](https://camo.githubusercontent.com/87725c5a1a5450b88aab67bfba27047a55ac8279b33875c7d1ad3a9d6eca94a4/68747470733a2f2f7472617669732d63692e6f72672f6d67626f6174656e672f656c6f7175656e742d736c75672e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/mgboateng/eloquent-slug)[![Total Downloads](https://camo.githubusercontent.com/7ee5e3b7bb8e5b32f582c413d549e8beed18575d351145d8941c2c40be806277/68747470733a2f2f706f7365722e707567782e6f72672f6d67626f6174656e672f656c6f7175656e742d736c75672f646f776e6c6f616473)](https://packagist.org/packages/mgboateng/eloquent-slug)[![Latest Stable Version](https://camo.githubusercontent.com/ee3b69dce5503edfa0c27efbe2f63ca1ab8031450720bcb2f0147bd896b39b30/68747470733a2f2f706f7365722e707567782e6f72672f6d67626f6174656e672f656c6f7175656e742d736c75672f762f737461626c65)](https://packagist.org/packages/mgboateng/eloquent-slug)[![License](https://camo.githubusercontent.com/2b6001012e8851231984f96beb767f5bc7b2f1cca259727829b75759543f0618/68747470733a2f2f706f7365722e707567782e6f72672f6d67626f6174656e672f656c6f7175656e742d736c75672f6c6963656e7365)](https://packagist.org/packages/mgboateng/eloquent-slug)

The package provides a trait that allows you to save a unique slugs to your database seamlessly by just specifying the seperator, source and destination field to generate a slug. It is very fast and very light on resources as it makes just a single database call when creating a model and two when updating as opposed to looping recurcively over the database to generate a unique slug.

Installation
------------

[](#installation)

You can install the package through composer `composer require mgboateng/eloquent-slugs` or through your composer json file:

```
{
    "require": {
        "mgboateng/eloquent-slugs" : "~0.2"
    }
}
```

Usage
-----

[](#usage)

To use the package you simply add the Slugging trait to you model and set `protected $slugSettings`property as below:

```
