afiqiqmal/hashslug-laravel

HashSlug for Laravel Model

1.2.0 2018-08-22 14:08 UTC

This package is auto-updated.

Last update: 2024-10-29 03:58:52 UTC


README

HashSlug Id for laravel

Installation

NOTE: Depending on your version of Laravel, you should install a different version of the package:

  1. Install the package via Composer:

    $ composer require afiqiqmal/hashslug-laravel

    The package will automatically register itself with Laravel 5.5.

    ...
    Afiqiqmal\LaraHashSlug\LaraHashSlugProvider::class,
    ...
  2. Optionally, publish the configuration file if you want to change any defaults:

    php artisan vendor:publish --provider="Afiqiqmal\LaraHashSlug\LaraHashSlugProvider"

Usage

use UseHashSlug Trait class in any model you need

class User extends Model {
   use UseHashSlug;
   
   //optional. default : "hashslug". 
   protected $hash_column = "hash_column";
}

Configuration

Default hashslug.php. publish provider if you want to change any defaults

return [
    'salt'     => env('HASHID_SALT', 'lara-hash-slug'),
    'length'   => env('HASHID_LENGTH', 12),
    'alphabet' => env('HASHID_ALPHABET', 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890'),
    'unique'   => env('HASHID_UNIQUE', true),
];