shiftechafrica / shift-code-generator
This package generates code in relation to year, date and month. For instance, it uses A - Z letters for months.
Installs: 2 367
Dependents: 0
Suggesters: 0
Security: 0
Stars: 1
Watchers: 1
Forks: 1
Open Issues: 0
Requires
- illuminate/support: ^5.8|^6.0|^7.0|^8.0|^9.0|^10
- webpatser/laravel-uuid: ^3.0|^4.0
README
Introduction
This package generates code in relation to year, date and month. For instance, it uses A - Z letters for months. For example 1E1NKJDQVW code 1 rep number of years, E rep month and 1 rep date while NKJDQVW is a random string. This library mimics the mpesa-transaction-id.
Installing
The recommended way to install shift-code-generator is through Composer.
# Install package via composer
composer require shiftechafrica/shift-code-generator
Next, run the Composer command to install the latest stable version of shiftechafrica/shift-code-generator:
# Update package via composer
composer update shiftechafrica/shift-code-generator --lock
After installing, the package will be auto discovered, But if need you may run:
# run for auto discovery <-- If the package is not detected automatically -->
composer dump-autoload
Then run this, to get the config/shift-code-generator.php for your own configurations:
# run this to get the configuration file at config/shift-code-generator.php <-- read through it --> php artisan vendor:publish --provider="ShiftechAfrica\CodeGenerator\ShiftCodeGeneratorServiceProvider"
A config/shift-code-generator.php file will be created, so if you want to use the database follow the next step on how to seed. The following add to your .env file.
YEAR_OF_START=2020 #pass the year that your application is launched USE_DATABASE=false #pass true if you want to use the database and false to use your default YEAR_OF_START
You will have to add this in the database/seeds/DatabaseSeeder. To ensure we seed some data to set the default dates that will be used in generating the codes:
/** * Seed the application's database. * * @return void */ public function run() { // other seeds... $this->call(\ShiftechAfrica\CodeGenerator\Seeds\ShiftCodeGeneratorFactory::class); }
Usage
Follow the steps below on how to use the shift-code-generator:
How to use the Library
How to generate the code...
use ShiftechAfrica\CodeGenerator\ShiftCodeGenerator; /** * ---------------------------- * Generate the code here * ----------------------------------------------------------------------- * Code will be generated in the format of Y-M-D + 7 random characters * ----------------------------------------------------------------------- * @return string */ public function generateCode() { return (new ShiftCodeGenerator())->generate();// in the generate method you can pass an int value like 5,4 or any to get the length of the code you want }
Version Guidance
Security Vulnerabilities
For any security vulnerabilities, please email to Shiftech Africa.
License
This package is open-source, licensed under the MIT license.