A Hashids service provider for Laravel
Hashids is small PHP library to generate YouTube-like ids from numbers. Use it when you don't want to expose your database ids to the user: http://hashids.org/php
Require this package, with Composer, in the root directory of your project.
$ composer require junityco/laravel-hashids
Add the service provider to
config/app.php in the
If you want you can use the facade. Add the reference in
config/app.php to your aliases array.
'Hashids' => Junity\Hashids\Facades\Hashids::class
Laravel Hashids requires connection configuration. To get started, you'll need to publish all vendor assets:
$ php artisan vendor:publish --provider="Junity\Hashids\HashidsServiceProvider"
This will create a
config/hashids.php file in your app that you can modify to set your configuration. Also, make sure you check for changes to the original config file in this package between releases.
use Junity\Hashids\Facades\Hashids; $id = Hashids::encode(1, 2, 3); // o2fXhV $numbers = Hashids::decode($id); // [1, 2, 3]
There are other methods in this package that are not documented here. For documentation visit the Hashids package homepage.