Package Data | |
---|---|
Maintainer Username: | nanokaweb |
Maintainer Contact: | git@kduma.tk (Krystian Duma) |
Package Create Date: | 2016-02-16 |
Package Last Update: | 2016-02-16 |
Home Page: | |
Language: | PHP |
License: | MIT |
Last Refreshed: | 2024-11-20 03:01:01 |
Package Statistics | |
---|---|
Total Downloads: | 10 |
Monthly Downloads: | 1 |
Daily Downloads: | 0 |
Total Stars: | 0 |
Total Watchers: | 1 |
Total Forks: | 0 |
Total Open Issues: | 0 |
Allows using tokens (HashIDs) instead of id in Laravel Eloquent models.
Add the package to the require section of your composer.json and run composer update
"kduma/eloquent-tokenable": "^1.1"
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
$model->token
- Generate tokensModel::whereToken($id)->first()
- Find by token. (whereToken
is query scope)A special thanks to creators of hashids, a PHP class that this package is based.
View this package on Packagist.org: kduma/eloquent-tokenable