kduma/eloquent-tokenable

Allows using tokens (HashIDs) instead of id in Laravel Eloquent models.
176 6
Install
composer require kduma/eloquent-tokenable
Latest Version:v3.0.0
PHP:^8.3
License:MIT
Last Updated:Apr 8, 2026
Links: GitHub  ·  Packagist
Maintainer: kduma

Eloquent Tokenable

Latest Stable Version Total Downloads License

Eloquent trait for exposing Hashids-based tokens on Laravel models instead of numeric IDs.

Full documentation: opensource.duma.sh/libraries/php/eloquent-tokenable

Requirements

  • PHP ^8.3
  • Laravel ^13.0

Installation

composer require kduma/eloquent-tokenable

Usage

use KDuma\Eloquent\Tokenable;
use KDuma\Eloquent\Attributes\HasToken;

#[HasToken(length: 10)]
class Order extends Model
{
    use Tokenable;
}
$order = Order::find(1);
echo $order->token; // e.g. "k3Zx9mPqW2"

$order = Order::whereToken('k3Zx9mPqW2')->first();

Related Packages

veelasky/laravel-hashid

HashId Implementation on Laravel Eloquent ORM

204,992 46
funfirst/laravel-hashids

HashId Implementation on Laravel Eloquent ORM

18 0
naabster/laravel-eloquent-hashids

Automatically generate hashids in Laravel for a new Eloquent Model.

7,045 16
nanokaweb/eloquent-tokenable

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

11 0
cline/strongly-typed-id

Strongly-typed ID value objects for PHP with support for UUID, ULID, NanoID, GUI...

6,207 0