shiftechafrica/shift-code-generator

This package generates code in relation to year, date and month. For instance, it uses A - Z letters for months.

v1.5.0 2023-02-24 16:08 UTC

This package is auto-updated.

Last update: 2024-04-24 18:35:39 UTC


README

68747470733a2f2f73686966746563686166726963612e636f6d2f696d672f6c6f676f2e706e67

Be in the next level
68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6973737565732f53484946544543482d4146524943412f73686966742d636f64652d67656e657261746f722e737667 68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f666f726b732f53484946544543482d4146524943412f73686966742d636f64652d67656e657261746f722e737667 68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f73746172732f53484946544543482d4146524943412f73686966742d636f64652d67656e657261746f722e737667 68747470733a2f2f706f7365722e707567782e6f72672f73686966746563686166726963612f73686966742d636f64652d67656e657261746f722f762f737461626c65 68747470733a2f2f706f7365722e707567782e6f72672f73686966746563686166726963612f73686966742d636f64652d67656e657261746f722f646f776e6c6f616473

68747470733a2f2f692e70696e696d672e636f6d2f6f726967696e616c732f63652f36392f34662f63653639346635363036333664666663663432656366343064346632663936322e676966

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

Version Status Packagist Namespace Repo
1.x Latest shiftechafrica/shift-code-generator ShiftechAfrica\CodeGenerator v1.4.7

Security Vulnerabilities

For any security vulnerabilities, please email to Shiftech Africa.

License

This package is open-source, licensed under the MIT license.