Download the PHP package juststeveking/laravel-key-factory without Composer
On this page you can find all versions of the php package juststeveking/laravel-key-factory. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download juststeveking/laravel-key-factory
More information about juststeveking/laravel-key-factory
Files in juststeveking/laravel-key-factory
Package laravel-key-factory
Short Description A simple package to generate Eloquent Model Keys
License MIT
Homepage https://github.com/juststeveking/laravel-key-factory
Informations about the package laravel-key-factory
A simple package to generate Eloquent Model Keys
Laravel Key Factory is a simple package to generate Eloquent Model Keys for your models easily. This is something I do quite often, instead of using UUID's which can be quite unfriendly to look at, I use Model keys which are unique strings generated for each model.
Installation
You can install the package via composer:
You can publish and run the migrations with:
You can publish the config file with:
This is the contents of the published config file:
Usage
This is a very simple to use package. There are two available methods to generate the key:
Using the Key Factory
Using the Str helper
Eloquent Integration
There is an eloquent model trait available to use called HasKey
which will:
When you are creating an eloquent model, the trait will be booted. It will get the first 3 characters of the Model name, force them to lowercase and append a "_" and use this as the prefix for the Key Factory
An example:
- User Model:
use_12345678909876543212
- Project Model:
pro_12345678909876543212
Currently this isn't a configured option as it is easy to override or implement yourself.
Testing
Changelog
Please see CHANGELOG for more information on what has changed recently.
Contributing
Please see CONTRIBUTING for details.
Security Vulnerabilities
Please review our security policy on how to report security vulnerabilities.
Credits
- Steve McDougall
- All Contributors
License
The MIT License (MIT). Please see License File for more information.
All versions of laravel-key-factory with dependencies
spatie/laravel-package-tools Version ^1.4.3
illuminate/contracts Version ^8.37 || 9.x