PHPackages                             actengage/sluggable - 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. [Utility &amp; Helpers](/categories/utility)
4. /
5. actengage/sluggable

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

actengage/sluggable
===================

A simple trait to ensure Laravel models have slugs.

v7.0.1(3mo ago)02.1k↓80%1MITPHPPHP ^8.2CI failing

Since Mar 7Pushed 3mo agoCompare

[ Source](https://github.com/actengage/sluggable)[ Packagist](https://packagist.org/packages/actengage/sluggable)[ RSS](/packages/actengage-sluggable/feed)WikiDiscussions master Synced today

READMEChangelog (2)Dependencies (14)Versions (31)Used By (1)

Sluggable
=========

[](#sluggable)

A simple package for managing "slugs" on Eloquent models. Sluggable is a trait for Eloquent models to ensure a slug exists for the model and is saved in a column.

### Installation

[](#installation)

```
composer require actengage/sluggable

```

### Implementation

[](#implementation)

Add the `Sluggable` trait to your model.

```
namespace App\Models;

use Actengage\Sluggable\Sluggable;
use Illuminate\Database\Eloquent\Model;

class Page extends Model
{
    use Sluggable;

    protected $fillable = [
        'title', 'slug',
    ];
}
```

### Basic Example

[](#basic-example)

```
$page = Page::create([
    'title' => 'This is some title',
]);

$page->slug; // 'this-is-some-title'
```

### PHP Attributes

[](#php-attributes)

You can use PHP attributes to declaratively configure sluggable behavior instead of overriding methods.

#### `#[Slug]` — Set the qualifier

[](#slug--set-the-qualifier)

The qualifier is the model attribute used to generate the slug. Defaults to `title`.

```
use Actengage\Sluggable\Slug;

#[Slug('name')]
class Product extends Model
{
    use Sluggable;
}
```

#### `#[SlugAttribute]` — Set the slug column

[](#slugattribute--set-the-slug-column)

The column where the slug is stored. Defaults to `slug`.

```
use Actengage\Sluggable\SlugAttribute;

#[SlugAttribute('url_slug')]
class Product extends Model
{
    use Sluggable;
}
```

#### `#[SlugDelimiter]` — Set the delimiter

[](#slugdelimiter--set-the-delimiter)

The character used to separate words in the slug. Defaults to `-`.

```
use Actengage\Sluggable\SlugDelimiter;

#[SlugDelimiter('_')]
class Product extends Model
{
    use Sluggable;
}
```

#### `#[PreventDuplicateSlugs]` — Control duplicate prevention

[](#preventduplicateslugs--control-duplicate-prevention)

By default, duplicate slugs are prevented by appending an incrementing number. Use this attribute to disable that behavior.

```
use Actengage\Sluggable\PreventDuplicateSlugs;

#[PreventDuplicateSlugs(false)]
class Product extends Model
{
    use Sluggable;
}
```

#### Combining attributes

[](#combining-attributes)

```
use Actengage\Sluggable\PreventDuplicateSlugs;
use Actengage\Sluggable\Slug;
use Actengage\Sluggable\SlugAttribute;
use Actengage\Sluggable\SlugDelimiter;

#[Slug('name')]
#[SlugAttribute('url_slug')]
#[SlugDelimiter('_')]
#[PreventDuplicateSlugs(false)]
class Product extends Model
{
    use Sluggable;
}
```

### Finding by Slug

[](#finding-by-slug)

```
$page = Page::findBySlug('this-is-some-title');
```

### Slug Scope

[](#slug-scope)

```
$page = Page::slug('this-is-some-title')->first();
```

### Duplicate Slug Prevention

[](#duplicate-slug-prevention)

By default, Sluggable prevents duplicate slugs by appending an incrementing number.

```
Page::create(['title' => 'test']); // slug: 'test'
Page::create(['title' => 'test']); // slug: 'test-1'
Page::create(['title' => 'test']); // slug: 'test-2'
```

This can be disabled with the `#[PreventDuplicateSlugs]` attribute or by setting the property on the model:

```
class Page extends Model
{
    use Sluggable;

    protected $preventDuplicateSlugs = false;
}
```

### Publishing a New Release

[](#publishing-a-new-release)

This package uses [changesets](https://github.com/changesets/changesets) for automated versioning and releases.

1. Create a branch and make your changes
2. Add a changeset describing the change: ```
    pnpm changeset

    ```

    Select the bump level (patch, minor, or major) and write a summary. See the [changeset skill](.claude/skills/changeset.md) for semver rules specific to this package.
3. Open a PR — CI runs Pint, PHPStan, Rector, and Pest
4. Merge the PR — the release workflow creates a "Version Packages" PR that bumps the version in `package.json` and updates `CHANGELOG.md`
5. Review and merge the "Version Packages" PR — a git tag and GitHub Release are created automatically

###  Health Score

53

—

FairBetter than 96% of packages

Maintenance80

Actively maintained with recent releases

Popularity21

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity84

Battle-tested with a long release history

 Bus Factor1

Top contributor holds 80% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~116 days

Recently: every ~153 days

Total

23

Last Release

107d ago

Major Versions

v2.0.0 → v3.0.02022-08-05

v3.0.2 → v4.0.02023-07-11

v4.1.0 → v5.0.02024-07-03

v5.0.0 → v6.0.02024-07-11

v6.1.1 → v7.0.02026-03-17

PHP version history (6 changes)0.1.0PHP &gt;=7.1

v1.1.0PHP &gt;=7.1|^7.2.5

v1.2.0PHP &gt;=7.0

v2.0.0PHP ^8.0

v4.0.0PHP ^8.1

v6.0.0PHP ^8.2

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/33735047?v=4)[actengage](/maintainers/actengage)[@actengage](https://github.com/actengage)

---

Top Contributors

[![actengage](https://avatars.githubusercontent.com/u/33735047?v=4)](https://github.com/actengage "actengage (12 commits)")[![github-actions[bot]](https://avatars.githubusercontent.com/in/15368?v=4)](https://github.com/github-actions[bot] "github-actions[bot] (3 commits)")

---

Tags

sluggableslugs

###  Code Quality

TestsPest

Static AnalysisPHPStan, Rector

Code StyleLaravel Pint

### Embed Badge

![Health badge](/badges/actengage-sluggable/health.svg)

```
[![Health](https://phpackages.com/badges/actengage-sluggable/health.svg)](https://phpackages.com/packages/actengage-sluggable)
```

###  Alternatives

[markwalet/nova-modal-response

A Laravel Nova asset for Modal responses on an action.

17878.9k](/packages/markwalet-nova-modal-response)[crumbls/layup

A visual page builder plugin for Filament 5 — Divi-style grid layouts with extensible widgets.

592.6k2](/packages/crumbls-layup)[team-nifty-gmbh/tall-datatables

Server-side rendered datatables for Laravel and Livewire

1320.9k4](/packages/team-nifty-gmbh-tall-datatables)[tomshaw/electricgrid

A feature-rich Livewire package designed for projects that require dynamic, interactive data tables.

119.4k](/packages/tomshaw-electricgrid)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
