PHPackages                             nanokaweb/eloquent-tokenable - 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. nanokaweb/eloquent-tokenable

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

nanokaweb/eloquent-tokenable
============================

Allows using tokens (HashIDs) instead of id in Laravel Eloquent models.

1.2.0(10y ago)011MITPHPPHP &gt;=5.4.0

Since Jan 31Pushed 10y agoCompare

[ Source](https://github.com/nanokaweb/L5-eloquent-tokenable)[ Packagist](https://packagist.org/packages/nanokaweb/eloquent-tokenable)[ RSS](/packages/nanokaweb-eloquent-tokenable/feed)WikiDiscussions master Synced 3w ago

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

L5-eloquent-tokenable
=====================

[](#l5-eloquent-tokenable)

[![Latest Stable Version](https://camo.githubusercontent.com/050c2b871a673064edd26ee2a1f47d375bbb68a81fbdaab60935eba9cc13833f/68747470733a2f2f706f7365722e707567782e6f72672f6b64756d612f656c6f7175656e742d746f6b656e61626c652f762f737461626c652e737667)](https://packagist.org/packages/kduma/eloquent-tokenable)[![Total Downloads](https://camo.githubusercontent.com/402beb914a2ae7ec81e070bfe95f6c7e222f3088714acdbb9f1dc01ebf87f56b/68747470733a2f2f706f7365722e707567782e6f72672f6b64756d612f656c6f7175656e742d746f6b656e61626c652f646f776e6c6f6164732e737667)](https://packagist.org/packages/kduma/eloquent-tokenable)[![Latest Unstable Version](https://camo.githubusercontent.com/af690c0014b31b0771e78a015474c4845ba9287a76a78bf536043d30d4603782/68747470733a2f2f706f7365722e707567782e6f72672f6b64756d612f656c6f7175656e742d746f6b656e61626c652f762f756e737461626c652e737667)](https://packagist.org/packages/kduma/eloquent-tokenable)[![License](https://camo.githubusercontent.com/014414ae1056ccb12e6849625ff669a129f12fc9d3c7a2044bad604cd9160f78/68747470733a2f2f706f7365722e707567782e6f72672f6b64756d612f656c6f7175656e742d746f6b656e61626c652f6c6963656e73652e737667)](https://packagist.org/packages/kduma/eloquent-tokenable)[![SensioLabsInsight](https://camo.githubusercontent.com/de1a2a880ba181ee3e15366ddc88c205a5edaaafcefdc93bb3783f3a86b66807/68747470733a2f2f696e73696768742e73656e73696f6c6162732e636f6d2f70726f6a656374732f37366261383763322d643563312d343531362d616632332d3364333866323939303134352f6d696e692e706e67)](https://insight.sensiolabs.com/projects/76ba87c2-d5c1-4516-af23-3d38f2990145)

Allows using tokens (HashIDs) instead of id in Laravel Eloquent models.

Setup
=====

[](#setup)

Add the package to the require section of your composer.json and run `composer update`

```
"kduma/eloquent-tokenable": "^1.1"

```

Prepare models
==============

[](#prepare-models)

In your model add following lines:

```
use \KDuma\Eloquent\Tokenable;
protected $appends = array('token');

```

Optionally you can add also:

- `protected $salt = 'SALT';`
    A salt for making hashes. Default is table name. This salt is added to your `APP_KEY`.
- `protected $length = 10;`
    A salt length. Default is 10.
- `protected $alphabet = 'qwertyuiopasdfghjklzxcvbnm1234567890';`
    A hash alphabet. Default is `abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890`

Usage
=====

[](#usage)

- `$model->token` - Generate tokens
- `Model::whereToken($id)->first()` - Find by token. (`whereToken` is query scope)

Hashids
=======

[](#hashids)

A special thanks to creators of [hashids](https://github.com/ivanakimov/hashids.php), a PHP class that this package is based.

Packagist
=========

[](#packagist)

View this package on Packagist.org: [kduma/eloquent-tokenable](https://packagist.org/packages/kduma/eloquent-tokenable)

###  Health Score

26

—

LowBetter than 41% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity5

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity62

Established project with proven stability

 Bus Factor1

Top contributor holds 84.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 ~76 days

Recently: every ~95 days

Total

6

Last Release

3782d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/15981417?v=4)[nanokaweb](/maintainers/nanokaweb)[@nanokaweb](https://github.com/nanokaweb)

---

Top Contributors

[![kduma](https://avatars.githubusercontent.com/u/1062582?v=4)](https://github.com/kduma "kduma (11 commits)")[![stephane-monnot](https://avatars.githubusercontent.com/u/6066368?v=4)](https://github.com/stephane-monnot "stephane-monnot (2 commits)")

---

Tags

laraveleloquenthashids

### Embed Badge

![Health badge](/badges/nanokaweb-eloquent-tokenable/health.svg)

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

###  Alternatives

[kirschbaum-development/eloquent-power-joins

The Laravel magic applied to joins.

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

A MongoDB based Eloquent model and Query builder for Laravel

7.1k8.0M87](/packages/mongodb-laravel-mongodb)[spatie/laravel-sluggable

Generate slugs when saving Eloquent models

1.5k12.4M293](/packages/spatie-laravel-sluggable)[watson/validating

Eloquent model validating trait.

9733.4M53](/packages/watson-validating)[cybercog/laravel-love

Make Laravel Eloquent models reactable with any type of emotions in a minutes!

1.2k322.4k1](/packages/cybercog-laravel-love)[spiritix/lada-cache

A Redis based, automated and scalable database caching layer for Laravel

591452.8k2](/packages/spiritix-lada-cache)

PHPackages © 2026

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