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

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

netsells/hash-model-ids
=======================

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

v2.0.0(2y ago)035.0k↓50%2MITPHPPHP ^8.2

Since Nov 7Pushed 2y ago2 watchersCompare

[ Source](https://github.com/netsells/hash-model-ids)[ Packagist](https://packagist.org/packages/netsells/hash-model-ids)[ RSS](/packages/netsells-hash-model-ids/feed)WikiDiscussions 2.x Synced 2d ago

READMEChangelog (5)Dependencies (6)Versions (8)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 Netsells\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 netsells/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

34

—

LowBetter than 75% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity28

Limited adoption so far

Community11

Small or concentrated contributor base

Maturity64

Established project with proven stability

 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 ~84 days

Total

7

Last Release

828d ago

Major Versions

v1.2.0 → 2.x-dev2024-03-28

PHP version history (2 changes)v1.0.0PHP ^8.1

2.x-devPHP ^8.2

### Community

Maintainers

![](https://www.gravatar.com/avatar/624c4f6bab3e31a7f022c26be6166a2c362a2d769675f585eda44c07e1693a43?d=identicon)[tomchkk](/maintainers/tomchkk)

---

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)")

---

Tags

laraveleloquentidshashidsdynamicnetsells

### Embed Badge

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

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

###  Alternatives

[psalm/plugin-laravel

Psalm plugin for Laravel

3355.3M346](/packages/psalm-plugin-laravel)[yajra/laravel-oci8

Oracle DB driver for Laravel via OCI8

8793.2M25](/packages/yajra-laravel-oci8)[watson/validating

Eloquent model validating trait.

9803.5M54](/packages/watson-validating)[laravel/ai

The official AI SDK for Laravel.

1.0k3.2M193](/packages/laravel-ai)[roots/acorn

Framework for Roots WordPress projects built with Laravel components.

9762.4M131](/packages/roots-acorn)[laravel/mcp

Rapidly build MCP servers for your Laravel applications.

77022.3M151](/packages/laravel-mcp)

PHPackages © 2026

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