PHPackages                             coderscantina/hashidable - 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. coderscantina/hashidable

ActiveLibrary

coderscantina/hashidable
========================

An adapted bridge for using hashids in Laravel models.

v1.1.1(1y ago)05.1k↓100%MITPHPPHP ~7.3||^8.0

Since May 19Pushed 1y ago1 watchersCompare

[ Source](https://github.com/coderscantina/hashidable)[ Packagist](https://packagist.org/packages/coderscantina/hashidable)[ RSS](/packages/coderscantina-hashidable/feed)WikiDiscussions main Synced today

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

Hashidable from Coder's Cantina
===============================

[](#hashidable-from-coders-cantina)

> An adapted bridge for using [laravel-hashids](https://github.com/vinkla/laravel-hashids) in Laravel models.

Features
--------

[](#features)

- Hashid route model binding
- Individual salt per model
- Optional individual configuration per model
- Helper methods for encoding, decoding and finding by hashid
- Collection support for working with multiple hashids
- Performance optimizations with factory caching

🏗 Install
---------

[](#-install)

Install the package via composer using this command:

```
composer require coderscantina/hashidable
```

⚙️ Usage
--------

[](#️-usage)

Add the Hashidable trait to your model

```
use CodersCantina\Hashidable;

class Foo extends Model
{
    use Hashidable;
}
```

### Route Model Binding

[](#route-model-binding)

Expose the hashid in a resource

```
class FooResource extends JsonResource
{
    /**
     * @param  \Illuminate\Http\Request  $request
     * @return array
     */
    public function toArray($request)
    {
        return [
            'id' => $this->getRouteKey(),
        ];
    }
}
```

Resolve the model via hashid in a controller

```
/**
* @param  \App\Models\Foo  $foo
* @return \Illuminate\Http\Response
*/
public function show(Foo $foo)
{
    return new FooResource($foo);
}
```

### Working with Single Models/IDs

[](#working-with-single-modelsids)

Static methods to work with hashIds:

```
Foo::encodeHashId(1);             // Convert ID to hashid
Foo::decodeHashId('A3');          // Convert hashid to ID
Foo::findByHashId('A3');          // Find model by hashid
Foo::findByHashIdOrFail('A3');    // Find model by hashid or throw exception
```

### Working with Collections/Arrays

[](#working-with-collectionsarrays)

Methods for working with multiple models or IDs:

```
// Encode multiple IDs
Foo::encodeHashIds([1, 2, 3]);    // Returns array of hashids

// Decode multiple hashids
Foo::decodeHashIds(['A3', 'B7']); // Returns array of IDs

// Find multiple models by hashids
Foo::findByHashIds(['A3', 'B7']); // Returns collection of models
```

### Custom Configuration

[](#custom-configuration)

Overwrite config with a model like `App\User::class`

```
# config/hashids.php

'connections' => [

    'main' => [
        'salt' => env('HASHIDS_SALT'),
        'length' => 8,
        'alphabet' => '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ',
    ],

    \App\User::class => [
        'salt' => env('HASHIDS_SALT'),
        'length' => 5,
        'alphabet' => '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ',
    ],

],
```

See for more information [Route Model Binding](https://laravel.com/docs/master/routing#route-model-binding)

###  Health Score

36

—

LowBetter than 83% of packages

Maintenance49

Moderate activity, may be stable

Popularity19

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity54

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 91.7% 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 ~94 days

Recently: every ~34 days

Total

8

Last Release

377d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/605b58449a3fff7658eba249cf6cad34ed7a577f7d72f673c1b858ce3a97f311?d=identicon)[badmike](/maintainers/badmike)

---

Top Contributors

[![badmike](https://avatars.githubusercontent.com/u/1019002?v=4)](https://github.com/badmike "badmike (11 commits)")[![kburton-dev](https://avatars.githubusercontent.com/u/10101978?v=4)](https://github.com/kburton-dev "kburton-dev (1 commits)")

---

Tags

laravelhashidsLaravel-hashids

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/coderscantina-hashidable/health.svg)

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

###  Alternatives

[vinkla/hashids

A Hashids bridge for Laravel

2.1k12.9M65](/packages/vinkla-hashids)[cybercog/laravel-optimus

An Optimus bridge for Laravel. Id obfuscation based on Knuth's multiplicative hashing method.

192560.3k](/packages/cybercog-laravel-optimus)[veelasky/laravel-hashid

HashId Implementation on Laravel Eloquent ORM

45161.0k3](/packages/veelasky-laravel-hashid)[naabster/laravel-eloquent-hashids

Automatically generate hashids in Laravel for a new Eloquent Model.

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

A Hashids bridge for Laravel

183.2k](/packages/lingxi-hashids)

PHPackages © 2026

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