Download the PHP package veelasky/laravel-hashid without Composer
On this page you can find all versions of the php package veelasky/laravel-hashid. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Informations about the package laravel-hashid
Laravel HashId
Automatic HashId generator for your eloquent model.
Version Compatibilities
Laravel HashId | PHP Version | Laravel 5.* | Laravel 6.* | Laravel 7.* | Laravel 8.* | Laravel 9.* | Laravel 10.* |
---|---|---|---|---|---|---|---|
1.x |
>=7.0 |
:white_check_mark: | :white_check_mark: | :x: | :x: | :x: | :x: |
2.x |
>=7.2 - <= 8.0 |
:x: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :x: |
3.0 |
>=7.4 || >= 8.0 |
:x: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :x: |
3.1 |
>= 8.0 |
:x: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: |
4.x |
>= 8.1 |
:x: | :x: | :x: | :x: | :x: | :white_check_mark: |
Install
With laravel package auto discovery, this will automatically add this package to your laravel application.
TLDR
Simply add HashableId
trait on any of your eloquent model you are intending to use with HashId.
Example:
Usage
With Eloquent Model
By default, all hash calculation will be calculated at runtime, but sometime you want to persist the hashed id to the database.
NOTE: when using persisting model, all database query will be check againts the table itself, except:
$model->hash
will always be calculated at runtime.
Salt
The salt is generated automatically based on your app key and hash_alphabet. If you need to use the same salt between different projects, you can set the HASHID_SALT
environment variable.
Route binding
When HashableId trait is used, base getRouteKey()
and resolveRouteBinding()
are overwritten to use the HashId as route key.
In-Depth Coverage
This package use repository pattern to store all instantiated implementation of HashId\HashId
class, this to achieve different hash result on every eloquent models defined with HashableId
trait.
However you can opt-out to not using any eloquent model or implementing your own logic to the repository.
If you're using single table inheritance model, where you want to has the same calculated hash across all inherited models, use $hashKey
property, this will result the calculation remain the same across all inherited model.
You can also specify the length and characters of the hashed Id with HASHID_LENGTH
and HASHID_ALPHABET
environment variable respectively, or you can publish the configuration file using this command:
Extra: Validation Rules
You can also use this as validation rules, simply add this rule to your validator.
License
MIT License
All versions of laravel-hashid with dependencies
hashids/hashids Version ^4.0|^5.0
illuminate/contracts Version >=6.18
illuminate/config Version >=6.18
illuminate/support Version >=6.18
illuminate/validation Version >=6.18
illuminate/database Version >=6.18