New

Just launched: Vueblocks, a brand-new search engine for Vue packages! Explore Vueblocks →

nanokaweb/eloquent-tokenable

Allows using tokens (HashIDs) instead of id in Laravel Eloquent models.
11
Install
composer require nanokaweb/eloquent-tokenable
Latest Version:1.2.0
PHP:>=5.4.0
Laravel:5
License:MIT
Last Updated:Feb 16, 2016
Links: GitHub  ·  Packagist
Maintainer: nanokaweb

L5-eloquent-tokenable

Latest Stable Version Total Downloads Latest Unstable Version License SensioLabsInsight

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

Setup

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

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

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

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

Hashids

A special thanks to creators of hashids, a PHP class that this package is based.

Packagist

View this package on Packagist.org: kduma/eloquent-tokenable

Related Packages

kduma/eloquent-tokenable

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

176 6
envivolink/eloquent-hashids

Automatically generate hashids in Laravel for a new Eloquent Model.

10,972 0
rossbearman/eloquent-calamari

Obfuscate incrementing IDs with Sqids for Laravel and Eloquent.

8,604 4
naabster/laravel-eloquent-hashids

Automatically generate hashids in Laravel for a new Eloquent Model.

7,045 16
veelasky/laravel-hashid

HashId Implementation on Laravel Eloquent ORM

260,701 48

Version History

Version Released PHP Laravel License
1.2.0 >=5.4.0 5.* MIT
v1.1.0 >=5.4.0 5.* MIT
v1.0.3 >=5.4.0 5.0.* MIT
v1.0.2 >=5.4.0 5.0.* MIT
v1.0.1 >=5.4.0 5.0.* MIT