Download the PHP package alexander-fuchs/hashidable without Composer
On this page you can find all versions of the php package alexander-fuchs/hashidable. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download alexander-fuchs/hashidable
More information about alexander-fuchs/hashidable
Files in alexander-fuchs/hashidable
Package hashidable
Short Description Auto Hashids for Laravel Models and Routes
License MIT
Informations about the package hashidable
Hashidable
Hashidable uses hashids to obfuscate Laravel route ids.
Installation
Note: This package is built to work with Laravel versions greater than 10. It may work in older version, but this has not been tested.
Setup
Import the Hashidable
trait and add it to your model.
Usage
Route Model Binding
Assuming we have a route resource defined as follows:
This package does not affect route model bindings, the only difference is, instead of placing the id in the generated route, it uses the hashid instead.
So, route('users.show', $user)
returns /users/3RwQaeoOR1E7qjYy
;
When you define your controller that auto-resolves a model in the parameters, it will work as always.
Configuring
First, publish the config file using:
The available configuration options are:
Per-Model Configuration
You can also extend the global configuration on a per-model basis. To do this, your model should implement the Altinum\Hashidable\HashidableConfigInterface
and define the hashidableConfig()
method on the model.
This method returns an array or subset of options similar to the global configuration.
FAQs
Where are the generated hashes stored?
Hashidable does not touch the database to store any sort of metadata. What it does instead is use an internal encoder/decoder to dynamically calculate the hashes.License
MIT