kduma/eloquent-tokenable
Eloquent Tokenable
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
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