PHPackages                             hedgehog-lab/hash-model-ids - 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. hedgehog-lab/hash-model-ids

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

hedgehog-lab/hash-model-ids
===========================

Dynamically create a hash of an Eloquent model id value to avoid exposing a record's actual database id.

3.x-dev(yesterday)00MITPHPPHP ^8.2

Since Jan 17Pushed yesterdayCompare

[ Source](https://github.com/hedgehoglab-engineering/hash-model-ids)[ Packagist](https://packagist.org/packages/hedgehog-lab/hash-model-ids)[ RSS](/packages/hedgehog-lab-hash-model-ids/feed)WikiDiscussions 3.x Synced today

READMEChangelogDependencies (6)Versions (4)Used By (0)

Hash Model Ids
==============

[](#hash-model-ids)

Dynamically create a hash of an Eloquent model id value to avoid exposing a record's actual database id.

Features
--------

[](#features)

```
use HedgehogLab\HashModelIds\HashesModelIdsTrait;

class Model extends BaseModel
{
    use HashesModelIdsTrait;
}
```

Use the `HashesModelIdsTrait` in an Eloquent model to enable the following functionality:

- Access a model's hashed id value: `$model->hashed_id`
- Filter a model by an array of or a single hashed id:
    - `Model::whereHashedId($hashedId)`
    - `Model::whereHashedIds($hashedIds)`
- Define routes with models bound by their hashed id: ```
    Route::get('models/{model}', function (Model $model) {
        return $model;
    });

    $url = url("models/$model->hashed_id");
    ```
- Check for model existence in form request classes using a bespoke rule, optionally including additional chained constraints: ```
    public function rules()
    {
        return [
            'hashed_id' => [
                ExistsWithHashedIdRule::make(Model::class)
                    ->where(function ($query) {
                        $query->where('type', 'test');
                    })
                    ->where('foo', 'bar'),
            ],
        ];
    }
    ```

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

[](#installation)

Install the package with:

`composer require hedgehog-lab/hash-model-ids`

Publish the package config file:

`php artisan vendor:publish --tag=hash-model-ids-config`

Optionally set a `HASH_MODEL_IDS_SALT` in `.env`.

Translations
------------

[](#translations)

Publish the package translations file:

`php artisan vendor:publish --tag=hash-model-ids-lang`

Development
-----------

[](#development)

Sometimes, during development, it can be awkward dealing with hashed ids. Set `HASH_MODEL_IDS_ENABLED=false` in your environment file to enable use of a (configurable) prefixed version of a model's actual id rather than the default hashed version.

Testing
-------

[](#testing)

`./vendor/bin/phpunit`

###  Health Score

39

—

LowBetter than 85% of packages

Maintenance100

Actively maintained with recent releases

Popularity0

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity43

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 70.6% 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 ~441 days

Total

3

Last Release

1d ago

Major Versions

1.x-dev → 2.x-dev2024-03-28

2.x-dev → 3.x-dev2026-06-18

PHP version history (2 changes)1.x-devPHP ^8.1

2.x-devPHP ^8.2

### Community

Maintainers

![](https://www.gravatar.com/avatar/967f8fc19e4b61cc07cd6d69357e2424171236c2f903c23ba6675ceda4f5708e?d=identicon)[will-c-f](/maintainers/will-c-f)

---

Top Contributors

[![tomchkk](https://avatars.githubusercontent.com/u/6698306?v=4)](https://github.com/tomchkk "tomchkk (24 commits)")[![bensherred](https://avatars.githubusercontent.com/u/22666637?v=4)](https://github.com/bensherred "bensherred (6 commits)")[![will-hedgehog-lab](https://avatars.githubusercontent.com/u/97068224?v=4)](https://github.com/will-hedgehog-lab "will-hedgehog-lab (4 commits)")

---

Tags

laraveleloquentidshashidsdynamicnetsellshedgehog-lab

### Embed Badge

![Health badge](/badges/hedgehog-lab-hash-model-ids/health.svg)

```
[![Health](https://phpackages.com/badges/hedgehog-lab-hash-model-ids/health.svg)](https://phpackages.com/packages/hedgehog-lab-hash-model-ids)
```

###  Alternatives

[psalm/plugin-laravel

Psalm plugin for Laravel

3325.1M337](/packages/psalm-plugin-laravel)[watson/validating

Eloquent model validating trait.

9743.4M53](/packages/watson-validating)[yajra/laravel-oci8

Oracle DB driver for Laravel via OCI8

8723.1M23](/packages/yajra-laravel-oci8)[kirschbaum-development/eloquent-power-joins

The Laravel magic applied to joins.

1.6k29.9M42](/packages/kirschbaum-development-eloquent-power-joins)[laravel/ai

The official AI SDK for Laravel.

9782.1M157](/packages/laravel-ai)[veelasky/laravel-hashid

HashId Implementation on Laravel Eloquent ORM

45180.7k3](/packages/veelasky-laravel-hashid)

PHPackages © 2026

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