PHPackages                             khaleds/voucher - 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. khaleds/voucher

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

khaleds/voucher
===============

Coupons and promotional codes generator for Laravel.

v1.0.0(3y ago)5332MITPHP

Since Mar 12Pushed 3y ago1 watchersCompare

[ Source](https://github.com/khaledAbodaif/laravel-voucher-package)[ Packagist](https://packagist.org/packages/khaleds/voucher)[ RSS](/packages/khaleds-voucher/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (1)DependenciesVersions (3)Used By (0)

[![enter image description here](https://camo.githubusercontent.com/e8ae2fcc5a48456ac6c7cb6b4bfc4419babf39643ed9b57deb5129e0f617cce7/68747470733a2f2f74342e667463646e2e6e65742f6a70672f30332f32392f31302f39372f3336305f465f3332393130393737345f695473796a7a4c55354f396361674a3955686168684e46325a646b57344f48632e6a7067)](https://camo.githubusercontent.com/e8ae2fcc5a48456ac6c7cb6b4bfc4419babf39643ed9b57deb5129e0f617cce7/68747470733a2f2f74342e667463646e2e6e65742f6a70672f30332f32392f31302f39372f3336305f465f3332393130393737345f695473796a7a4c55354f396361674a3955686168684e46325a646b57344f48632e6a7067)

Laravel Voucher Package
=======================

[](#laravel-voucher-package)

Coupons and voucher codes checker. you can create voucher with many conditions that fit your business.

**Available Conditions**

columndescriptioncodecoupon or voucher codeis\_availablecheck if this voucher available or notmax\_usesthe max number of using this vouchermax\_uses\_userthe max number of using this voucher per single userstarts\_atstart date for this voucher to be publishedexpires\_atend date for this voucher to be closedall of this conditions the package checking it .

> what about you have a coupon for a specific users ,vendors or customers beside the other conditions ofcourse , or even i need to apply coupon for category , service or products all of them or specific ones ?

**voucher\_implementation\_id ;)**this forigen id related with table takes \[class path,value as json\]. you can add your voucher audience as a morph table in **voucher\_audiences** that tacks which usable\_type as a table name, usable\_id as model id ,is\_all bool that mean all records in this table and voucher\_id . in the **voucher\_implementations** table you can find the implementation record for each voucher the default one is applied . the default implementation just check for model table ,id or is\_all check in voucher\_audiences table

List of content
===============

[](#list-of-content)

- Installation
- How Does It Work?
- How to use
- Advanced use

Installation
============

[](#installation)

```
composer require khaleds/voucher

```

### Migrate table

[](#migrate-table)

```
php artisan make:migration

```

### Seeder

[](#seeder)

Add this to your **DatabaseSeeder** class in run method

```
	use Khaleds\Voucher\Seeder\VoucherImplementaionSeeder;

    $this->call(VoucherImplementaionSeeder::class);
```

How Does It Work?
=================

[](#how-does-it-work)

### Vouchers table

[](#vouchers-table)

This table contain the voucher conditions like

columndescriptioncodecoupon or voucher codeis\_availablecheck if this voucher available or notmax\_usesthe max number of using this vouchermax\_uses\_userthe max number of using this voucher per single userstarts\_atstart date for this voucher to be publishedexpires\_atend date for this voucher to be closedOther columns

columndescriptiondiscount\_amountThe amount to discountis\_fixedWhether or not the "discount\_amount" is a percentage or a fixed pricemax\_usesNumber of users that use this voucheramount\_capAmount to apply it if the price greater than capusesThe total number of uses for this voucherIf you want more condition like specific models or ids like i want this voucher for all accounts table or users table or the users with some ids you can do that in this table

### Vouchers Audiences table

[](#vouchers-audiences-table)

This table contain

columndescriptionusable\_typeTable nameusable\_idThe id that you want to use vouchervoucher\_idThe voucher that you want to apply this condition on itis\_allIf you want to make all users in this table can use the voucher> the relation is one to many so you can add many ids if you want per voucher

### User Voucher table

[](#user-voucher-table)

This table contain the users that applied to the voucher added when you use function **apply**

How to use
==========

[](#how-to-use)

you have 2 static classes

```
	// $code  : voucher code
	// model  : which model uses this voucher
	// amount : the amount that you want to apply voucher on it
	// return : voucher object if passed all conditions ex if not passed
    VoucherFactory::get(string $code,Model $user,float $amount)->check()->get()

    // if you pass 0 that mean the voucher applied and not used
	// applay will add the model to voucher if passes the conditions and increment uses column
    VoucherFactory::get(string $code,Model $user,float $amount)->check()->apply(1)->get()
```

### If you want to avoid all checks and apply the voucher

[](#if-you-want-to-avoid-all-checks-and-apply-the-voucher)

```
VoucherFactory::get(string $code,Model $user,float $amount)->apply(bool $is_used, string $code, Model $model))
```

Advanced use
============

[](#advanced-use)

> what about you have an extra conditions like you want to add voucher with only country ,service , products or categories

### Using

[](#using)

```
VoucherFactory::get(string $code,Model $user)->check()
// it tacks table name as a key and array of ids
->append(
  [
  "categories" => [1,2,3],
  "products" => [1,2,3],
  ]
)
->apply(1)->get()
```

you just need to add your audiences in **Vouchers Audiences table**

if you want to overwrite the implementation class change the class path in **voucher\_implementations** table and extend from DefaultVoucher class

###  Health Score

24

—

LowBetter than 32% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity14

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity46

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

1161d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/137bd906128eb90ecbed8bdec5efcd310c5d7abe8fd20ed2538f59334566b73f?d=identicon)[khaledAbodaif](/maintainers/khaledAbodaif)

---

Top Contributors

[![khaledAbodaif](https://avatars.githubusercontent.com/u/32595431?v=4)](https://github.com/khaledAbodaif "khaledAbodaif (17 commits)")

### Embed Badge

![Health badge](/badges/khaleds-voucher/health.svg)

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

PHPackages © 2026

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