Skip to content

kduma-OSS/LV-eloquent-tokenable

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

37 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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();

About

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

Topics

Resources

License

Stars

6 stars

Watchers

1 watching

Forks

Packages

 
 
 

Contributors

Languages