PHPackages                             a4anthony/coupon - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. a4anthony/coupon

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

a4anthony/coupon
================

E-commerce coupon generator and dashboard

v1.0.0(5y ago)5323MITPHPCI failing

Since May 28Pushed 5y ago1 watchersCompare

[ Source](https://github.com/a4anthony/coupon)[ Packagist](https://packagist.org/packages/a4anthony/coupon)[ RSS](/packages/a4anthony-coupon/feed)WikiDiscussions master Synced 5d ago

READMEChangelogDependencies (7)Versions (2)Used By (0)

Coupon Generator for Laravel
============================

[](#coupon-generator-for-laravel)

[![Total Downloads](https://camo.githubusercontent.com/db34130351fa9a2c0e7f3a5fc4b450dce5b9ff1deeb7fa16971c4aaea34ba6bc/68747470733a2f2f706f7365722e707567782e6f72672f6134616e74686f6e792f636f75706f6e2f646f776e6c6f6164732e7376673f666f726d61743d666c6174)](https://packagist.org/packages/a4anthony/coupon)[![Latest Stable Version](https://camo.githubusercontent.com/a6c5f8cbbc93e974f0cff0086adb6d359ded802df5afb0366f79f597356db0ed/68747470733a2f2f706f7365722e707567782e6f72672f6134616e74686f6e792f636f75706f6e2f762f737461626c652e7376673f666f726d61743d666c6174)](https://packagist.org/packages/a4anthony/coupon)[![License](https://camo.githubusercontent.com/be9bf21d426a8b2b7fd9712483edef150cb0a03a1400c6f855f2fc918280b9f8/68747470733a2f2f706f7365722e707567782e6f72672f6134616e74686f6e792f636f75706f6e2f6c6963656e73652e7376673f666f726d61743d666c6174)](https://packagist.org/packages/a4anthony/coupon)

 [![](https://github.com/a4anthony/coupon/raw/master/Resources/assets/images/add.png?raw=true)](https://github.com/a4anthony/coupon/blob/master/Resources/assets/images/add.png?raw=true) [![](https://github.com/a4anthony/coupon/raw/master/Resources/assets/images/edit.png?raw=true)](https://github.com/a4anthony/coupon/blob/master/Resources/assets/images/edit.png?raw=true)

Installation Steps
------------------

[](#installation-steps)

### 1. Require the package

[](#1-require-the-package)

After creating your new Laravel application you can include the coupon package with the following command:

```
composer require a4anthony/coupon:1.0.0
```

### 2. Add the DB Credentials &amp; APP\_URL

[](#2-add-the-db-credentials--app_url)

Next make sure to create a new database and add your database credentials to your .env file:

```
DB_HOST=localhost
DB_DATABASE=homestead
DB_USERNAME=homestead
DB_PASSWORD=secret

```

You will also want to update your website URL inside of the `APP_URL` variable inside the .env file:

```
APP_URL=http://localhost:8000

```

### 3. Install coupon generator

[](#3-install-coupon-generator)

Lastly, we can install the coupon generator. You can do this either with or without dummy data. The dummy data will include 1 admin account (if no users already exists) and 5 test coupons

To install the coupon generator without dummy simply run

```
php artisan coupon:install
```

If you prefer installing it with dummy run

```
php artisan coupon:install --with-dummy
```

If you encounter any issues with the installation, run the code below to autoload all classes and retry the installation

```
composer dump-autoload

```

And we're all good to go!

Start up a local development server with `php artisan serve` And, visit .

### Creating an Admin User

[](#creating-an-admin-user)

If you did go ahead with the dummy data, a user should have been created for you with the following login credentials:

> **email:** `admin@admin.com`
> **password:** `password`

If you did not install the dummy data and you wish to create a new admin user you can pass the `--create` flag, like so:

```
php artisan coupon:admin your@email.com --create
```

And you will be prompted for the user's name and password.

### 4. Register custom guards for the coupon generator

[](#4-register-custom-guards-for-the-coupon-generator)

Go to the the config folder and open the auth.php file. In the providers array, include the code below

```
'admin' => [
'driver' => 'eloquent',
'model' => \A4anthony\Coupon\Models\Admin::class,
]
```

In the same file, in the guards array, include the code below

```
'admin' => [
'redirectTo' => 'coupon.dashboard',
'driver' => 'session',
'provider' => 'admin',
],
```

### 5. Adjust the RedirectIfAuthenticated class to recognize custom guard

[](#5-adjust-the-redirectifauthenticated-class-to-recognize-custom-guard)

Go to app/Http/Middleware/RedirectIfAuthenticated.php and edit the handle() method to the code below:

```
    public function handle($request, Closure $next, $guard = null)
{
    if (Auth::guard($guard)->check()) {
        if ($guard == "admin") {
            return redirect()->route('coupon.dashboard');
        }
        return redirect(RouteServiceProvider::HOME);
    }

    return $next($request);
}
```

### 6. Register the custom middleware class

[](#6-register-the-custom-middleware-class)

app/Http/Middleware/RedirectIfAuthenticated.php and include the code below in the $routeMiddleware array

```
'admin' => \App\Http\Middleware\CouponAuthenticate::class

```

Configuring package
-------------------

[](#configuring-package)

Package can configured in the config/coupon.php file. You can configure timezone, change currency and include currency symbol and also set your error messages.

```
/*
|--------------------------------------------------------------------------
| Timezone
|--------------------------------------------------------------------------
|
| Here you can specify the coupon genrator timezone
|
*/

'timezone' => 'Africa/Lagos',

/*
|--------------------------------------------------------------------------
| Currency
|--------------------------------------------------------------------------
|
| Here you can specify the coupon genrator currency
|
*/
'currency' => 'NGN',

/*
|--------------------------------------------------------------------------
| Currency Codes
|--------------------------------------------------------------------------
|
| Here you can specify the coupon genrator currency codes
|
*/
'currency_code' => [
    'NGN' => '&#8358;',
    'USD' => '$',
    'EUR' => '€',
    'GBP' => '£',
],
/*
|--------------------------------------------------------------------------
| Error Messages
|--------------------------------------------------------------------------
|
| Here you can specify the coupon genrator error messages
|
*/
'error_msgs' => [
    'not_exist' => 'coupon does not exist',
    'not_valid' => 'coupon is not valid',
    'used' => 'coupon is already used by you',
    'exceeds' => 'coupon discount value is greater than amount',
]
```

Usage
-----

[](#usage)

Include the package with:

```
use A4anthony\Coupon\Facades\Coupon;
```

### 1. Validate coupon and get discount value

[](#1-validate-coupon-and-get-discount-value)

```
$customer_email = 'johndoe@gmail.com';
$amount = 50000;
$discount = 0;//set discount default value
$coupon_code = 'ANTHONYQXGA4';
try {
    Coupon::validate($coupon_code, $customer_email);
    $discount = Coupon::getDiscount($coupon_code, $amount);
    echo 'Coupon accepted';
} catch (Exception $e) {
    echo 'Message: ' . $e->getMessage();
}
```

### 2. Callback on successful payment

[](#2-callback-on-successful-payment)

```
Coupon::callback($coupon_code, $customer_email);
```

ENJOY!!!

 [![](https://github.com/a4anthony/coupon/raw/master/Resources/assets/images/dashboard1.png?raw=true)](https://github.com/a4anthony/coupon/blob/master/Resources/assets/images/dashboard1.png?raw=true)

Contributing
============

[](#contributing)

Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.

Please make sure to update tests as appropriate.

License
=======

[](#license)

[MIT](https://choosealicense.com/licenses/mit/)

###  Health Score

27

—

LowBetter than 49% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity14

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity55

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Unknown

Total

1

Last Release

2180d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/abb49ce1134199be75b90cca1654b65bb22cd40e9efbf7596150ffd0c7e41a13?d=identicon)[a4anthony](/maintainers/a4anthony)

---

Top Contributors

[![a4anthony](https://avatars.githubusercontent.com/u/55565463?v=4)](https://github.com/a4anthony "a4anthony (16 commits)")

---

Tags

laravelvouchercoupon

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/a4anthony-coupon/health.svg)

```
[![Health](https://phpackages.com/badges/a4anthony-coupon/health.svg)](https://phpackages.com/packages/a4anthony-coupon)
```

###  Alternatives

[barryvdh/laravel-ide-helper

Laravel IDE Helper, generates correct PHPDocs for all Facade classes, to improve auto-completion.

14.9k123.0M687](/packages/barryvdh-laravel-ide-helper)[frittenkeez/laravel-vouchers

Voucher system for Laravel 9+

5819.9k2](/packages/frittenkeez-laravel-vouchers)[interaction-design-foundation/laravel-geoip

Support for multiple Geographical Location services.

17221.0k3](/packages/interaction-design-foundation-laravel-geoip)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
