afiqiqmal / hashslug-laravel
HashSlug for Laravel Model
Installs: 357
Dependents: 0
Suggesters: 0
Security: 0
Stars: 2
Watchers: 2
Forks: 0
Open Issues: 0
Type:laravel
Requires
- php: ^7.0
- hashids/hashids: ^3.0
- illuminate/config: ~5.6.0
- illuminate/database: ~5.6.0
- illuminate/support: ~5.6.0
Requires (Dev)
- mockery/mockery: ^0.9.4
- orchestra/database: ~3.6.0
- orchestra/testbench: ~3.6.0
- phpunit/phpunit: ^7.3
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:
-
Install the package via Composer:
$ composer require afiqiqmal/hashslug-laravel
The package will automatically register itself with Laravel 5.5.
... Afiqiqmal\LaraHashSlug\LaraHashSlugProvider::class, ...
-
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), ];