PHPackages                             jaacu/laravel-model-hashids - 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. jaacu/laravel-model-hashids

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

jaacu/laravel-model-hashids
===========================

1.0.0(6y ago)326MITPHPPHP ^7.1

Since May 18Pushed 6y ago2 watchersCompare

[ Source](https://github.com/jaacu/laravel-model-hashids)[ Packagist](https://packagist.org/packages/jaacu/laravel-model-hashids)[ Docs](https://github.com/jaacu/laravel-model-hashids)[ RSS](/packages/jaacu-laravel-model-hashids/feed)WikiDiscussions master Synced today

READMEChangelogDependencies (5)Versions (2)Used By (0)

Laravel Model Hash Id
=====================

[](#laravel-model-hash-id)

[![Latest Version on Packagist](https://camo.githubusercontent.com/9bdcacb36266b8edf4a76a576e601997c978b046953aff19e27f8c1c04cf7cfd/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6a616163752f6c61726176656c2d6d6f64656c2d686173686964732e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/jaacu/laravel-model-hashids)[![Build Status](https://camo.githubusercontent.com/85400d7e0af859060b7e0b7b8e163a1f8fe74f367dce22c353c92c60d56e8513/68747470733a2f2f696d672e736869656c64732e696f2f7472617669732f6a616163752f6c61726176656c2d6d6f64656c2d686173686964732f6d61737465722e7376673f7374796c653d666c61742d737175617265)](https://travis-ci.org/jaacu/laravel-model-hashids)[![Quality Score](https://camo.githubusercontent.com/9f117930bff71070e7e1a943f1be05b96b5384e0cd2f1599dd6edc962bdb25b7/68747470733a2f2f696d672e736869656c64732e696f2f7363727574696e697a65722f672f6a616163752f6c61726176656c2d6d6f64656c2d686173686964732e7376673f7374796c653d666c61742d737175617265)](https://scrutinizer-ci.com/g/jaacu/laravel-model-hashids)[![Total Downloads](https://camo.githubusercontent.com/723cc30aad2b523fbdbbd574693fceabccde8b358ae5eda47ea0e64187c17b34/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6a616163752f6c61726176656c2d6d6f64656c2d686173686964732e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/jaacu/laravel-model-hashids)[![StyleCI](https://camo.githubusercontent.com/f12a1567dfd7dfd80f5a243adc500fbd97abf4928532371030d9fd7feb7e9240/68747470733a2f2f6769746875622e7374796c6563692e696f2f7265706f732f3138303436393530372f736869656c643f6272616e63683d6d6173746572)](https://github.styleci.io/repos/180469507)

Compatible with laravel version 5.8.x

This package allows you to use hashids in your models using the [vinkla/laravel-hashids](https://github.com/vinkla/laravel-hashids) package

This package includes the [vinkla/laravel-hashids](https://github.com/vinkla/laravel-hashids) package

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

[](#installation)

You can install the package via composer:

```
composer require jaacu/laravel-model-hashids
```

Usage
-----

[](#usage)

Add to your model migration the following code

```
...
$table->hashid();
...
```

Then simply add the UsesHashIds trait to your model

```
use Jaacu\LaravelModelHashids\Traits\UsesHashIds;

class MyModel extends Model
{
    use UsesHashIds;
}
```

Now using default laravel routing implicint binding will use the hashid insted of the normal id

### Examples

[](#examples)

A model using the trait UsesHashIds

```
$model = Model::first();
```

Generating url

```
route('model.show',$model); // output: http://mydomain/model/
```

Getting the hashid

```
$model->getId() // returns: the model
```

### Config

[](#config)

Publish the config file to change default behavior

```
php artisan vendor:publish --provider="Jaacu\LaravelModelHashids\LaravelModelHashidsServiceProvider"
```

By default the generated hashid follows this structure: app name + model name + model id hash

- app name is set by the app.config name and can be overwritten by setting a new 'short\_name' in the config/app.php file
- model name is set by the model class name
- model hash id is set by the model 'id' hash

This package shares the config file from [vinkla/laravel-hashids](https://github.com/vinkla/laravel-hashids)

In the config/hashids.php you can set the hash length and salt.

```
'connections' => [
    'main' => [
        'salt' => env('APP_KEY'), // Uses the env app key by default
        'length' => 6,
    ],
    'alternative' => [
        'salt' => 'your-salt-string',
        'length' => 'your-length-integer',
    ],
]
```

### Docs

[](#docs)

For more info on the hash functionality see [vinkla/laravel-hashids](https://github.com/vinkla/laravel-hashids)

### Changelog

[](#changelog)

Please see [CHANGELOG](CHANGELOG.md) for more information what has changed recently.

Contributing
------------

[](#contributing)

Please see [CONTRIBUTING](CONTRIBUTING.md) for details.

### Security

[](#security)

If you discover any security related issues, please email  instead of using the issue tracker.

Credits
-------

[](#credits)

- [Javier Cabello](https://github.com/jaacu)
- [All Contributors](../../contributors)

License
-------

[](#license)

The MIT License (MIT). Please see [License File](LICENSE.md) for more information.

Laravel Package Boilerplate
---------------------------

[](#laravel-package-boilerplate)

This package was generated using the [Laravel Package Boilerplate](https://laravelpackageboilerplate.com).

###  Health Score

26

—

LowBetter than 43% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity10

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity54

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 94.1% 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

Unknown

Total

1

Last Release

2550d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/ba454f1aacb32376f8924eb7565dad20cda2347e019059b1d5d5257c4fbe9461?d=identicon)[jaacu](/maintainers/jaacu)

---

Top Contributors

[![jaacu](https://avatars.githubusercontent.com/u/17502865?v=4)](https://github.com/jaacu "jaacu (16 commits)")[![scrutinizer-auto-fixer](https://avatars.githubusercontent.com/u/6253494?v=4)](https://github.com/scrutinizer-auto-fixer "scrutinizer-auto-fixer (1 commits)")

---

Tags

hashidhashidslaravellaravellaravel-model-hashidsjaacu

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/jaacu-laravel-model-hashids/health.svg)

```
[![Health](https://phpackages.com/badges/jaacu-laravel-model-hashids/health.svg)](https://phpackages.com/packages/jaacu-laravel-model-hashids)
```

###  Alternatives

[barryvdh/laravel-ide-helper

Laravel IDE Helper, generates correct PHPDocs for all Facade classes, to improve auto-completion.

14.9k123.0M686](/packages/barryvdh-laravel-ide-helper)[interaction-design-foundation/laravel-geoip

Support for multiple Geographical Location services.

17221.0k3](/packages/interaction-design-foundation-laravel-geoip)[nedwors/navigator

A Laravel package to ease defining navigation menus

433.1k](/packages/nedwors-navigator)[xefi/faker-php-laravel

Faker php integration with laravel

1915.1k](/packages/xefi-faker-php-laravel)[dcblogdev/laravel-junie

Install pre-configured guides for Jetbrains Junie

392.5k](/packages/dcblogdev-laravel-junie)

PHPackages © 2026

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