seguce92 / laravel-hashid by seguce92

Hashid for Laravel framework.
195
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-11-11 15:20:34
Package Statistics
Total Downloads: 195
Monthly Downloads: 5
Daily Downloads: 1
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