PHP code example of shiftechafrica / shift-code-generator

1. Go to this page and download the library: Download shiftechafrica/shift-code-generator library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

shiftechafrica / shift-code-generator example snippets


# run for auto discovery <-- If the package is not detected automatically -->
composer dump-autoload

# run this to get the configuration file at config/shift-code-generator.php <-- read through it -->
php artisan vendor:publish --provider="ShiftechAfrica\CodeGenerator\ShiftCodeGeneratorServiceProvider"

  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

    /**
     * Seed the application's database.
     *
     * @return void
     */
    public function run()
    {
         // other seeds...
         $this->call(\ShiftechAfrica\CodeGenerator\Seeds\ShiftCodeGeneratorFactory::class);
    }

   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
    }