Skip to content

Commit 8173258

Browse files
👽 👽 Updating code due to external API changes.
1 parent 1e2489f commit 8173258

1 file changed

Lines changed: 102 additions & 65 deletions

File tree

README.md

Lines changed: 102 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -1,116 +1,153 @@
1-
# <p align="center"><a href="https://shiftechafrica.com/" target="_blank"><img width="100" src="https://shiftechafrica.com/img/logo.png"></a></p>
1+
# <p align="center"><a href="https://shiftechafrica.com/" target="_blank"><img width="100" src="https://shiftechafrica.com/img/logo.png" alt="Shiftech Africa Logo"></a></p>
22

33
<p align="center">
44
<b>Be in the next level</b><br>
55
<a href="https://github.com/SHIFTECH-AFRICA/shift-code-generator/issues">
6-
<img src="https://img.shields.io/github/issues/SHIFTECH-AFRICA/shift-code-generator.svg">
6+
<img src="https://img.shields.io/github/issues/SHIFTECH-AFRICA/shift-code-generator.svg">
77
</a>
88
<a href="https://github.com/SHIFTECH-AFRICA/shift-code-generator/network/members">
9-
<img src="https://img.shields.io/github/forks/SHIFTECH-AFRICA/shift-code-generator.svg">
9+
<img src="https://img.shields.io/github/forks/SHIFTECH-AFRICA/shift-code-generator.svg">
1010
</a>
1111
<a href="https://github.com/SHIFTECH-AFRICA/shift-code-generator/stargazers">
12-
<img src="https://img.shields.io/github/stars/SHIFTECH-AFRICA/shift-code-generator.svg">
12+
<img src="https://img.shields.io/github/stars/SHIFTECH-AFRICA/shift-code-generator.svg">
1313
</a>
1414
<a href="https://packagist.org/packages/shiftechafrica/shift-code-generator">
15-
<img src="https://poser.pugx.org/shiftechafrica/shift-code-generator/v/stable">
15+
<img src="https://poser.pugx.org/shiftechafrica/shift-code-generator/v/stable">
1616
</a>
1717
<a href="https://packagist.org/packages/shiftechafrica/shift-code-generator">
18-
<img src="https://poser.pugx.org/shiftechafrica/shift-code-generator/downloads">
18+
<img src="https://poser.pugx.org/shiftechafrica/shift-code-generator/downloads">
1919
</a>
2020
<br><br>
21-
<img src="https://i.pinimg.com/originals/ce/69/4f/ce694f560636dffcf42ecf40d4f2f962.gif">
21+
<img src="https://i.pinimg.com/originals/ce/69/4f/ce694f560636dffcf42ecf40d4f2f962.gif" alt="Shift Code Generator Animation">
2222
</p>
2323

24-
## Introduction
25-
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.
26-
This library mimics the *mpesa-transaction-id*.
24+
---
2725

28-
## Installing
26+
## 🚀 Introduction
2927

30-
The recommended way to install shift-code-generator is through
31-
[Composer](http://getcomposer.org).
28+
**Shift Code Generator** is a lightweight Laravel/PHP package that generates unique alphanumeric codes based on the **year**, **month**, and **day**, followed by a randomized string.
29+
It’s ideal for applications that require sequential or time-based identifiers — such as **transaction IDs**, **invoice numbers**, or **reference codes**.
30+
31+
For example:
32+
`1E1NKJDQVW`
33+
- **1** → Represents the number of years since the start year
34+
- **E** → Represents the month (A–Z mapping)
35+
- **1** → Represents the day of the month
36+
- **NKJDQVW** → Randomly generated string
37+
38+
This logic mimics the behavior of **M-Pesa transaction IDs**, ensuring unique, traceable, and time-bound identifiers.
39+
40+
---
41+
42+
## ⚙️ Installation
43+
44+
Install via [Composer](https://getcomposer.org/):
3245

3346
```bash
34-
# Install package via composer
3547
composer require shiftechafrica/shift-code-generator
3648
```
3749

38-
Next, run the Composer command to install the latest stable version of *shiftechafrica/shift-code-generator*:
50+
Update to the latest version:
3951

4052
```bash
41-
# Update package via composer
42-
composer update shiftechafrica/shift-code-generator --lock
53+
composer update shiftechafrica/shift-code-generator --lock
4354
```
4455

45-
After installing, the package will be auto discovered, But if need you may run:
56+
If the package isn’t automatically discovered, run:
4657

47-
```php
48-
# run for auto discovery <-- If the package is not detected automatically -->
58+
```bash
4959
composer dump-autoload
5060
```
5161

52-
Then run this, to get the *config/shift-code-generator.php* for your own configurations:
62+
Publish the configuration file:
5363

54-
```php
55-
# run this to get the configuration file at config/shift-code-generator.php <-- read through it -->
64+
```bash
5665
php artisan vendor:publish --provider="ShiftechAfrica\CodeGenerator\ShiftCodeGeneratorServiceProvider"
5766
```
58-
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.
5967

60-
```php
61-
YEAR_OF_START=2020 #pass the year that your application is launched
62-
USE_DATABASE=false #pass true if you want to use the database and false to use your default YEAR_OF_START
68+
This will create a config file at:
69+
70+
```
71+
config/shift-code-generator.php
6372
```
6473

74+
---
75+
76+
## ⚙️ Configuration
6577

66-
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:
78+
In your `.env` file, add the following:
79+
80+
```dotenv
81+
YEAR_OF_START=2020 # The year your application was launched
82+
USE_DATABASE=false # Set to true to use database tracking, or false to use static year configuration
83+
```
84+
85+
If you enable database tracking, seed the database by adding this entry to your `DatabaseSeeder`:
6786

6887
```php
69-
/**
70-
* Seed the application's database.
71-
*
72-
* @return void
73-
*/
74-
public function run()
75-
{
76-
// other seeds...
77-
$this->call(\ShiftechAfrica\CodeGenerator\Seeds\ShiftCodeGeneratorFactory::class);
78-
}
88+
/**
89+
* Seed the application's database.
90+
*
91+
* @return void
92+
*/
93+
public function run()
94+
{
95+
// Other seeds...
96+
$this->call(\ShiftechAfrica\CodeGenerator\Seeds\ShiftCodeGeneratorFactory::class);
97+
}
7998
```
8099

81-
## Usage
82-
Follow the steps below on how to use the shift-code-generator:
100+
This ensures your application initializes with proper baseline data for generating codes dynamically.
83101

84-
#### How to use the Library
85-
How to generate the code...
102+
---
103+
104+
## 🧩 Usage
105+
106+
Generate unique codes easily within your application.
86107

87108
```php
88-
use ShiftechAfrica\CodeGenerator\ShiftCodeGenerator;
89-
/**
90-
* ----------------------------
91-
* Generate the code here
92-
* -----------------------------------------------------------------------
93-
* Code will be generated in the format of Y-M-D + 7 random characters
94-
* -----------------------------------------------------------------------
95-
* @return string
96-
*/
97-
public function generateCode()
98-
{
99-
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
100-
}
109+
use ShiftechAfrica\CodeGenerator\ShiftCodeGenerator;
110+
111+
/**
112+
* Generate a new Shift Code
113+
*
114+
* @return string
115+
*/
116+
public function generateCode()
117+
{
118+
return (new ShiftCodeGenerator())->generate();
119+
// Optionally pass an integer to set the random length, e.g. ->generate(5)
120+
}
121+
```
122+
123+
### Example Output
124+
125+
```text
126+
1E1NKJDQVW
101127
```
128+
- **1** = Year offset
129+
- **E** = Month letter
130+
- **1** = Day
131+
- **NKJDQVW** = Random string
132+
133+
---
134+
135+
## 🧭 Version Guidance
136+
137+
| Version | Status | Packagist | Namespace | Release |
138+
|----------|--------|------------|------------|----------|
139+
| **1.x** | ✅ Latest | `shiftechafrica/shift-code-generator` | `ShiftechAfrica\CodeGenerator` | [v1.5.2](https://github.com/SHIFTECH-AFRICA/shift-code-generator/releases/tag/v1.5.2) |
140+
141+
---
102142

143+
## 🛡️ Security Vulnerabilities
103144

104-
## Version Guidance
145+
If you discover a security vulnerability, please contact:
146+
📧 **[bugs@shiftechafrica.com](mailto:bugs@shiftechafrica.com)**
105147

106-
| Version | Status | Packagist | Namespace | Repo |
107-
|---------|------------|---------------------|--------------|---------------------------------------------------------------------------------------|
108-
| 1.x | Latest | `shiftechafrica/shift-code-generator` | `ShiftechAfrica\CodeGenerator` | [v1.5.2](https://github.com/SHIFTECH-AFRICA/shift-code-generator/releases/tag/v1.5.2) |
148+
---
109149

110-
[shift-code-generator-repo]: https://github.com/SHIFTECH-AFRICA/shift-code-generator.git
150+
## 📄 License
111151

112-
## Security Vulnerabilities
113-
For any security vulnerabilities, please email to [Shiftech Africa](mailto:bugs@shiftechafrica.com).
114-
115-
## License
116-
This package is open-source, licensed under the [MIT license](https://opensource.org/licenses/MIT).
152+
This package is open-source software licensed under the
153+
**[MIT License](https://opensource.org/licenses/MIT)**

0 commit comments

Comments
 (0)