Download the PHP package cirlmcesc/laravel-hashids without Composer
On this page you can find all versions of the php package cirlmcesc/laravel-hashids. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Informations about the package laravel-hashids
Laravel Hashids
TL;DR
Do not explicitly display the ID of the data in the interface or URI. Use the Trail on the Model to automatically encrypt the ID, and at the same time, it will correctly decrypt the instance of the class you want to inject into the route. It also provides quick methods to encrypt and decrypt the ID when you need. It provides some commands for testing. Inspired by vinkla/hashids.
Getting started
Install via composer
Require this package, with Composer, in the root directory of your project.
Configuration file
Artisan command will be published to config/
. The mode of operation can be customized by modifying parameters and attributes.
Usage
Use on Model
Use Model trait, you can use it quickly. Using trait on the model, you can quickly use it to automatically encrypt the ID when the model is serialized and the value of the field set by . It is also possible to not set this property and all fields ends with will be automatically encrypted.You can choose to set the property to prevent these fields from being encrypted. However, and are mutually exclusive. If both are set, an exception will be thrown when the model is serialized into an array. Of course, you can also choose to set the property to determine whether to encrypt only the ID field. If additional fields need to be encrypted and the field does not end with , then it is necessary to set to all fields ending with plus the fields that require additional encryption Only in this way can it work properly.
Use on Route
When injecting the model ID into routing or controller operations, it will automatically decode the ID. No additional action is required.
Use on Resource Class
When you use resource classes, model serialization does not go through Model Trait, so you need to encrypt the ID in the method of the resource class.The usage method allows for batch encryption of ID fields.
Use functions elsewhere
Quickly encrypt and decrypt. Some functions are provided.
Test command Artisan command can use encryption and decryption on the command line.