seguce92 / laravel-hashid by seguce92

Hashid for Laravel framework.
189
0
2
Package Data
Maintainer Username: seguce92
Maintainer Contact: seguce92@gmail.com (Sergio Gualberto Cruz Espinoza)
Package Create Date: 2017-05-02
Package Last Update: 2019-06-25
Home Page: http://mascodigo.net
Language: PHP
License: MIT
Last Refreshed: 2024-04-23 03:11:40
Package Statistics
Total Downloads: 189
Monthly Downloads: 0
Daily Downloads: 0
Total Stars: 0
Total Watchers: 2
Total Forks: 0
Total Open Issues: 0

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