PHPackages                             intervention/eloquent-hashid - 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. intervention/eloquent-hashid

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

intervention/eloquent-hashid
============================

Configurable HashId Trait for Laravel Eloquent models

2.0.0(2y ago)7731MITPHPPHP ^8.0

Since Feb 13Pushed 1y ago1 watchersCompare

[ Source](https://github.com/Intervention/eloquent-hashid)[ Packagist](https://packagist.org/packages/intervention/eloquent-hashid)[ Docs](http://intervention.io/)[ RSS](/packages/intervention-eloquent-hashid/feed)WikiDiscussions main Synced 1mo ago

READMEChangelogDependencies (1)Versions (7)Used By (0)

Intervention Eloquent HashID
============================

[](#intervention-eloquent-hashid)

[![Latest Version](https://camo.githubusercontent.com/553cd727ebcab729b39022ecf36da8433c13e3d8985705a06a6bf16cee0d8551/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f696e74657276656e74696f6e2f656c6f7175656e742d6861736869642e737667)](https://packagist.org/packages/intervention/eloquent-hashid)

This package provides a trait to easily encode and decode [hashids](https://github.com/vinkla/hashids) in your Eloquent models. Every model gets an attribute and a scope for hashid queries.

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

[](#installation)

You can install this package with Composer.

Require the package via Composer:

```
$ composer require intervention/eloquent-hashid

```

Laravel will automatically discover the packages service provider class.

Setup
-----

[](#setup)

After installation you're able to publish the configuration file to your Laravel application with the following command.

```
$ php artisan vendor:publish --provider="Intervention\EloquentHashid\Laravel\EloquentHashidServiceProvider"

```

You will find a new config file in `config/hashid.php`, which you can customize. **I strongly suggest to change at least the `salt_prefix` option to your own value.**

Now you can include the trait `Intervention\EloquentHashid\HasHashid` in your [Eloquent Model](https://laravel.com/docs/eloquent) to add the hashid features.

```
use Intervention\EloquentHashid\HasHashid;

class Item extends Model
{
    use HasHashid;
}
```

Usage
-----

[](#usage)

### Code Example

[](#code-example)

Every Eloquent Model gets a new `hashid` attribute, which is created based on the models classname, the key and the salt prefix. You're also able to query models with the now added `hashid()` scope.

#### Access hashid attribute

[](#access-hashid-attribute)

```
$item = App\Models\Item::find(123);

// access hashid attribute
$hashid = $item->hashid
```

#### Query models

[](#query-models)

```
// query model with scope
$item = App\Models\Item::hashid('Ma93ka')->firstOrFail();

// scope can also select multiple items by array
$item = App\Models\Item::hashid(['Ma93ka', 'Op92ae'])->get();

// scope query in one call
$item = App\Models\Item::findByHashid('Ma93ka');

// scope query in one call, throw exception if no model was found
$item = App\Models\Item::findByHashidOrFail('Ma93ka');
```

#### Route Model Binding

[](#route-model-binding)

Eloquent models can be resolved by their hashid in routes by defining a custom key.

```
use App\Models\Item;

Route::get('/items/{item:hashid}', function (Item $item) {
    return $item;
});
```

Authors
-------

[](#authors)

This library is developed and maintained by [Oliver Vogel](https://intervention.io)

License
-------

[](#license)

Intervention Eloquent HashID is licensed under the [MIT License](LICENSE).

###  Health Score

34

—

LowBetter than 77% of packages

Maintenance30

Infrequent updates — may be unmaintained

Popularity22

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity62

Established project with proven stability

 Bus Factor1

Top contributor holds 94.4% 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 ~179 days

Recently: every ~224 days

Total

6

Last Release

1021d ago

Major Versions

1.3.0 → 2.0.02023-08-01

PHP version history (3 changes)1.0.0PHP ^7.3

1.2.0PHP ^7.3|^8.0

2.0.0PHP ^8.0

### Community

Maintainers

![](https://www.gravatar.com/avatar/7d172b42b2c5b53e71e56589fed3fb3467234a1c266d31b697b1d7b451f4cfe8?d=identicon)[olivervogel](/maintainers/olivervogel)

---

Top Contributors

[![olivervogel](https://avatars.githubusercontent.com/u/884642?v=4)](https://github.com/olivervogel "olivervogel (17 commits)")[![ovogel-wigital](https://avatars.githubusercontent.com/u/60091414?v=4)](https://github.com/ovogel-wigital "ovogel-wigital (1 commits)")

---

Tags

laraveleloquenthashid

### Embed Badge

![Health badge](/badges/intervention-eloquent-hashid/health.svg)

```
[![Health](https://phpackages.com/badges/intervention-eloquent-hashid/health.svg)](https://phpackages.com/packages/intervention-eloquent-hashid)
```

###  Alternatives

[kirkbushell/eloquence

A set of extensions adding additional functionality and consistency to Laravel's awesome Eloquent library.

573970.0k1](/packages/kirkbushell-eloquence)[veelasky/laravel-hashid

HashId Implementation on Laravel Eloquent ORM

46168.5k3](/packages/veelasky-laravel-hashid)[rtconner/laravel-likeable

Trait for Laravel Eloquent models to allow easy implementation of a 'like' or 'favorite' or 'remember' feature.

394388.0k5](/packages/rtconner-laravel-likeable)[highsolutions/eloquent-sequence

A Laravel package for easy creation and management sequence support for Eloquent models with elastic configuration.

121130.3k](/packages/highsolutions-eloquent-sequence)[cybercog/laravel-nova-ban

A Laravel Nova banning functionality for your application.

40199.8k](/packages/cybercog-laravel-nova-ban)[naabster/laravel-eloquent-hashids

Automatically generate hashids in Laravel for a new Eloquent Model.

167.0k](/packages/naabster-laravel-eloquent-hashids)

PHPackages © 2026

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