Looking to hire Laravel developers? Try LaraJobs

laravel-hashids maintained by junityco

Description
A Hashids service provider for Laravel
Last update
2017/02/17 16:18 (dev-master)
License
Downloads
4 100

Comments
comments powered by Disqus

Hashids 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

Total Downloads Latest Version License

Installation

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 providers array.

Junity\Hashids\HashidsServiceProvider::class

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

Configuration

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.

Quick Example

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.