PHPackages                             codeboxr/coupondiscount - 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. codeboxr/coupondiscount

ActiveLibrary

codeboxr/coupondiscount
=======================

Coupon Discount

v1.0.5(2y ago)13665MITPHP ^7.4|^8.0|^8.1

Since Dec 23Compare

[ Source](https://github.com/codeboxrcodehub/coupondiscount)[ Packagist](https://packagist.org/packages/codeboxr/coupondiscount)[ RSS](/packages/codeboxr-coupondiscount/feed)WikiDiscussions Synced 1mo ago

READMEChangelog (4)Dependencies (2)Versions (6)Used By (0)

Coupon Discount php/laravel package
===================================

[](#coupon-discount-phplaravel-package)

[![](https://camo.githubusercontent.com/c0c7f425e48d46bccd0d67c49924b192b8714b9de23b6125263b6b370af8eb07/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f636f6465626f78722f636f75706f6e646973636f756e74)](https://camo.githubusercontent.com/c0c7f425e48d46bccd0d67c49924b192b8714b9de23b6125263b6b370af8eb07/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f636f6465626f78722f636f75706f6e646973636f756e74)[![](https://camo.githubusercontent.com/b6391fc8ac30b03c7cdc49805cdd384ee849c71bdaf761a08c8da4c8e2560bd9/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f73746172732f636f6465626f78722f636f75706f6e646973636f756e74)](https://camo.githubusercontent.com/b6391fc8ac30b03c7cdc49805cdd384ee849c71bdaf761a08c8da4c8e2560bd9/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f73746172732f636f6465626f78722f636f75706f6e646973636f756e74)

This is a PHP/Laravel package for Coupon Discount. This package can be used in laravel or without laravel/php projects. You can use this package for headless/rest implementation as well as blade or regular mode development. We created this package while working for a project and thought to made it release for all so that it helps. This package is available as regular php [composer package](https://packagist.org/packages/codeboxr/coupondiscount).

Requirements
------------

[](#requirements)

- PHP &gt;=7.4

Installation
------------

[](#installation)

```
composer require codeboxr/coupondiscount
```

Usage
-----

[](#usage)

If you are using laravel this package in laravel you have to publish migration first and migrate by the following command.

```
php artisan vendor:publish --provider="Codeboxr\CouponDiscount\CouponDiscountServiceProvider"
```

```
php artisan migrate
```

coupons and coupon\_histories two db table are created.

`Note:` If you are using raw PHP or other PHP framework you can have to import `copuondiscount/database/sql` SQL file manually in your database.

Action NameMethodExplanation[Create Coupon](https://github.com/codeboxrcodehub/coupondiscount#1-create-new-coupon)add($array)Create coupon code by add() method it taken a array. Array formate given below[Update Coupon](https://github.com/codeboxrcodehub/coupondiscount#2-update-coupon)update($array,$couponId)Coupon Update by update() method it's taken two parameter first parameter is an array and second parameter is coupon id[Remove Coupon](https://github.com/codeboxrcodehub/coupondiscount#3-remove-coupon)remove($couponId)Coupon Remove by remove() method it's taken one parameter. Parameter is Coupon id[Coupon List](https://github.com/codeboxrcodehub/coupondiscount#4-coupon-list)list()Fetch coupon list by list() method. You can chain any operation in Eluquarant after this method. For example: `list()->where('status',1)->get();`,`list()->take(5)->get();`,`list()->first();` etc[Coupon Validity](https://github.com/codeboxrcodehub/coupondiscount#5-coupon-validity-check)validity($couponCode, float $amount, string $userId, string $deviceName = null, string $ipaddress = null, string $vendorId = null)check coupon code validity by validity() method. It's take 6 parameter 3 parameter are required. 1st parameter is coupon code,second parameter is total amount,third parameter is user id,fourth parameter (optional) device name,fifth parameter (optional) is IP address and sixth parameter (optional) is vendor id or shop id[Coupon Apply](https://github.com/codeboxrcodehub/coupondiscount#6-coupon-apply)apply($array)Apply coupon in a cart amount by apply() method. apply method taken one parameter is array, example given below[Coupon History List](https://github.com/codeboxrcodehub/coupondiscount#7-coupon-history-list)history()Fetch coupon history list by history() method. You can chain any operation in Eluquarant after this method. For example: `history()->where('user_id',1)->get();`,`history()->take(5)->get();`,`history()->first();` etc[Remove History](https://github.com/codeboxrcodehub/coupondiscount#8-delete-coupon-history)historyDelete($historyId)Coupon History Remove by historyDelete() method it's taken one parameter. Parameter is Coupon history id### 1. Create new coupon

[](#1-create-new-coupon)

`*** For Using Laravel Application`

```
use Codeboxr\CouponDiscount\Facades\Coupon;
Coupon::add([
    'coupon_code'       => "", // (required) Coupon code
    'discount_type'     => "", // (required) coupon discount type. two type are accepted (1. percentage and 2. fixed)
    'discount_amount'   => "", // (required) discount amount or percentage value
    'start_date'        => "", // (required) coupon start date
    'end_date'          => "", // (required) coupon end date
    'status'            => "", // (required) two status are accepted. (for active 1 and for inactive 0)
    'minimum_spend'     => "", // (optional) for apply this coupon minimum spend amount. if set empty then it's take unlimited
    'maximum_spend'     => "", // (optional) for apply this coupon maximum spend amount. if set empty then it's take unlimited
    'use_limit'         => "", // (optional) how many times are use this coupon. if set empty then it's take unlimited
    'use_same_ip_limit' => "", // (optional) how many times are use this coupon in same ip address. if set empty then it's take unlimited
    'user_limit'        => "", // (optional) how many times are use this coupon a user. if set empty then it's take unlimited
    'use_device'        => "", // (optional) This coupon can be used on any device
    'multiple_use'      => "", // (optional) you can check manually by this multiple coupon code use or not
    'vendor_id'         => ""  // (optional) if coupon code use specific shop or vendor
]);

```

`*** For Using Raw php or other php framwork`

```
use Codeboxr\CouponDiscount\Services\CouponService;

$copuon = new CouponService([
    "driver"   => "", // (optional) database driver. By default it takes `mysql`
    "host"     => "", // (optional) database host. By default it takes `localhost`
    "username  => "", // (required) database user name.
    "password" => ""  // (required) database password,
]);

$copuon->add([
    'coupon_code'       => "", // (required) Coupon code
    'discount_type'     => "", // (required) coupon discount type. two type are accepted (1. percentage and 2. fixed)
    'discount_amount'   => "", // (required) discount amount or percentage value
    'start_date'        => "", // (required) coupon start date
    'end_date'          => "", // (required) coupon end date
    'status'            => "", // (required) two status are accepted. (for active 1 and for inactive 0)
    'minimum_spend'     => "", // (optional) for apply this coupon minimum spend amount. if set empty then it's take unlimited
    'maximum_spend'     => "", // (optional) for apply this coupon maximum spend amount. if set empty then it's take unlimited
    'use_limit'         => "", // (optional) how many times are use this coupon. if set empty then it's take unlimited
    'use_same_ip_limit' => "", // (optional) how many times are use this coupon in same ip address. if set empty then it's take unlimited
    'user_limit'        => "", // (optional) how many times are use this coupon a user. if set empty then it's take unlimited
    'use_device'        => "", // (optional) This coupon can be used on any device
    'multiple_use'      => "", // (optional) you can check manually by this multiple coupon code use or not
    'vendor_id'         => "" // (optional) if coupon code use specific shop or vendor
]);

```

### 2. Update coupon

[](#2-update-coupon)

`*** For Using Laravel Application`

```
use Codeboxr\CouponDiscount\Facades\Coupon;
Coupon::update([
    'coupon_code'       => "", // (required) Coupon code
    'discount_type'     => "", // (required) coupon discount type. two type are accepted (1. percentage and 2. fixed)
    'discount_amount'   => "", // (required) discount amount or percentage value
    'start_date'        => "", // (required) coupon start date
    'end_date'          => "", // (required) coupon end date
    'status'            => "", // (required) two status are accepted. (for active 1 and for inactive 0)
    'minimum_spend'     => "", // (optional) for apply this coupon minimum spend amount. if set empty then it's take unlimited
    'maximum_spend'     => "", // (optional) for apply this coupon maximum spend amount. if set empty then it's take unlimited
    'use_limit'         => "", // (optional) how many times are use this coupon. if set empty then it's take unlimited
    'use_same_ip_limit' => "", // (optional) how many times are use this coupon in same ip address. if set empty then it's take unlimited
    'user_limit'        => "", // (optional) how many times are use this coupon a user. if set empty then it's take unlimited
    'use_device'        => "", // (optional) This coupon can be used on any device
    'multiple_use'      => "", // (optional) you can check manually by this multiple coupon code use or not
    'vendor_id'         => "" // (optional) if coupon code use specific shop or vendor
], $couponId);

```

`*** For Using Raw php or other php framwork`

```
$copuon->update([
    'coupon_code'       => "", // (required) Coupon code
    'discount_type'     => "", // (required) coupon discount type. two type are accepted (1. percentage and 2. fixed)
    'discount_amount'   => "", // (required) discount amount or percentage value
    'start_date'        => "", // (required) coupon start date
    'end_date'          => "", // (required) coupon end date
    'status'            => "", // (required) two status are accepted. (for active 1 and for inactive 0)
    'minimum_spend'     => "", // (optional) for apply this coupon minimum spend amount. if set empty then it's take unlimited
    'maximum_spend'     => "", // (optional) for apply this coupon maximum spend amount. if set empty then it's take unlimited
    'use_limit'         => "", // (optional) how many times are use this coupon. if set empty then it's take unlimited
    'use_same_ip_limit' => "", // (optional) how many times are use this coupon in same ip address. if set empty then it's take unlimited
    'user_limit'        => "", // (optional) how many times are use this coupon a user. if set empty then it's take unlimited
    'use_device'        => "", // (optional) This coupon can be used on any device
    'multiple_use'      => "", // (optional) you can check manually by this multiple coupon code use or not
    'vendor_id'         => "" // (optional) if coupon code use specific shop or vendor
], $couponId);

```

### 3. Remove coupon

[](#3-remove-coupon)

`*** For Using Laravel Application`

```
use Codeboxr\CouponDiscount\Facades\Coupon;

Coupon::remove($couponId)

```

`*** For Using Raw php or other php framwork`

```
$copuon->remove($couponId);

```

### 4. Coupon List

[](#4-coupon-list)

`*** For Using Laravel Application`

```
use Codeboxr\CouponDiscount\Facades\Coupon;

Coupon::list()->get();

```

`*** For Using Raw php or other php framwork`

```
$copuon->list()->get();

```

### 5. Coupon validity check

[](#5-coupon-validity-check)

```
use Codeboxr\CouponDiscount\Facades\Coupon;

Coupon::validity("CBX23",1200,1,"app","192.168.0.1",5);

```

`*** For Using Raw php or other php framwork`

```
$copuon->validity("CBX23",1200,1,"app","192.168.0.1",5);

```

`note: validity() method first 3 method parameter are required others optional`

### 6. Coupon apply

[](#6-coupon-apply)

```
use Codeboxr\CouponDiscount\Facades\Coupon;

Coupon::apply([
    "code"        => "", // coupon code. (required)
    "amount"      => "", // total amount to apply coupon. must be a numberic number (required)
    "user_id"     => "", // user id (required)
    "order_id"    => "", // order id (required)
    "device_name" => "", // device name (optional)
    "ip_address"  => "", // ip address (optional)
    "vendor_id"   => "", // vendor id (optional)
]);

```

`*** For Using Raw php or other php framwork`

```
$copuon->apply([
    "code"        => "", // coupon code. (required)
    "amount"      => "", // total amount to apply coupon. must be a numberic number (required)
    "user_id"     => "", // user id (required)
    "order_id"    => "", // order id (required)
    "device_name" => "", // device name (optional)
    "ip_address"  => "", // ip address (optional)
    "vendor_id"   => "", // vendor id (optional)
]);

```

### 7. Coupon history list

[](#7-coupon-history-list)

`*** For Using Laravel Application`

```
use Codeboxr\CouponDiscount\Facades\Coupon;

Coupon::history()->get();

```

`*** For Using Raw php or other php framwork`

```
$copuon->history()->get();

```

### 8. Delete coupon history

[](#8-delete-coupon-history)

`*** For Using Laravel Application`

```
use Codeboxr\CouponDiscount\Facades\Coupon;

Coupon::historyDelete($historyId)

```

`*** For Using Raw php or other php framwork`

```
$copuon->historyDelete($historyId);

```

Contributing
------------

[](#contributing)

Contributions to the Coupon Discount package are welcome. Please note the following guidelines before submitting your pull request.

- Follow [PSR-4](http://www.php-fig.org/psr/psr-4/) coding standards.

License
-------

[](#license)

Coupon Discount package is licensed under the [MIT License](http://opensource.org/licenses/MIT).

Copyright 2023 [Codeboxr](https://codeboxr.com)

###  Health Score

31

—

LowBetter than 68% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity22

Limited adoption so far

Community12

Small or concentrated contributor base

Maturity58

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 83.7% 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

Every ~166 days

Total

4

Last Release

741d ago

### Community

Maintainers

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

![](https://www.gravatar.com/avatar/81623abb96d5e8d150207d166effa3d73f4853bb9006cb9df7bef67ff65853bf?d=identicon)[codeboxr](/maintainers/codeboxr)

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

---

Top Contributors

[![dipudey](https://avatars.githubusercontent.com/u/50619501?v=4)](https://github.com/dipudey "dipudey (36 commits)")[![manchumahara](https://avatars.githubusercontent.com/u/204452?v=4)](https://github.com/manchumahara "manchumahara (3 commits)")[![deepakdeb](https://avatars.githubusercontent.com/u/49678313?v=4)](https://github.com/deepakdeb "deepakdeb (2 commits)")[![kampit](https://avatars.githubusercontent.com/u/6607338?v=4)](https://github.com/kampit "kampit (2 commits)")

### Embed Badge

![Health badge](/badges/codeboxr-coupondiscount/health.svg)

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

###  Alternatives

[laravel/cashier

Laravel Cashier provides an expressive, fluent interface to Stripe's subscription billing services.

2.5k25.9M107](/packages/laravel-cashier)[laravel/scout

Laravel Scout provides a driver based solution to searching your Eloquent models.

1.7k49.4M479](/packages/laravel-scout)[tucker-eric/eloquentfilter

An Eloquent way to filter Eloquent Models

1.8k4.8M26](/packages/tucker-eric-eloquentfilter)[yajra/laravel-oci8

Oracle DB driver for Laravel via OCI8

8703.0M17](/packages/yajra-laravel-oci8)[mehdi-fathi/eloquent-filter

Eloquent Filter adds custom filters automatically to your Eloquent Models in Laravel.It's easy to use and fully dynamic, just with sending the Query Strings to it.

450191.6k1](/packages/mehdi-fathi-eloquent-filter)[pressbooks/pressbooks

Pressbooks is an open source book publishing tool built on a WordPress multisite platform. Pressbooks outputs books in multiple formats, including PDF, EPUB, web, and a variety of XML flavours, using a theming/templating system, driven by CSS.

44643.1k1](/packages/pressbooks-pressbooks)

PHPackages © 2026

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