Skip to content
Hashid for laravel framework
PHP
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
src
README.md
composer.json

README.md

Laravel-Hashid

Install

$ composer require seguce92/laravel-hashid

Add service provider in 'config/app.php'

'providers' => [
    ...
    Seguce92\LaravelHashid\ServiceProvider::class,
    ...
],

Add alias in 'config/app.php' (optionnal)

'aliases' => [
    ...
    'Hashid' => Seguce92\LaravelHashid\Facade::class,
    ...
],

Publish configuration

$ php artisan vendor:publish

Configuration

/**
 * Min lenght of generated Hashid
 */
'min_lenght' => 8,

/*
 * Alphabet use in Hashid generation
 */
'alphabet'   => 'aAbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyYzZ0123456789',

Usage

// without custom value salt (default is app key and 'laravel-hashid')
$hashid = Hashid::encode($id); // return string

$id = Hashid::decode($hasid); // return integer

// with custom value salt
$hashid = Hashid::encode($id, $salt); // return string

$id = Hashid::decode($hasid, $salt); // return integer
You can’t perform that action at this time.