Package Data | |
---|---|
Maintainer Username: | veelasky |
Maintainer Contact: | veelasky@pm.com (Rifki Alhuraibi) |
Package Create Date: | 2018-01-22 |
Package Last Update: | 2024-06-05 |
Home Page: | |
Language: | PHP |
License: | MIT |
Last Refreshed: | 2024-11-23 03:12:04 |
Package Statistics | |
---|---|
Total Downloads: | 99,857 |
Monthly Downloads: | 4,363 |
Daily Downloads: | 142 |
Total Stars: | 42 |
Total Watchers: | 1 |
Total Forks: | 17 |
Total Open Issues: | 4 |
Automatic HashId generator for your eloquent model.
composer require veelasky/laravel-hashid
With laravel package auto discovery, this will automatically add this package to your laravel application.
Simply add HashableId
trait on any of your eloquent model you are intending to use with HashId.
Example:
use Illuminate\Database\Eloquent\Model;
use Veelasky\LaravelHashId\Eloquent\HashableId;
class User extends Model {
use HashableId;
...
}
// instance of user
$user = User::find(1);
// generate HashId
$user->hash;
// querying for user with specific hash
$user = User::byHash($hash); // $hash: insert any hash that you want to check.
// querying for user with specific hash and throw EloquentModelNotFound exception
$user = User::byHashOrFail($hash);
// convert id to hash from User static instance;
User::idToHash($id);
// convert hash to id from User static instance;
User::hashToId($hash);