PHPackages                             trexology/promocodes - 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. trexology/promocodes

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

trexology/promocodes
====================

Promotional Codes Generator for Laravel 5.1

1.1(9y ago)121.2k5[2 PRs](https://github.com/Trexology/Promocodes/pulls)MITPHPPHP &gt;=5.4.0

Since Nov 24Pushed 2y ago1 watchersCompare

[ Source](https://github.com/Trexology/Promocodes)[ Packagist](https://packagist.org/packages/trexology/promocodes)[ Docs](https://github.com/trexology/promocodes)[ RSS](/packages/trexology-promocodes/feed)WikiDiscussions master Synced 3w ago

READMEChangelog (2)Dependencies (1)Versions (9)Used By (0)

Promocodes
==========

[](#promocodes)

[![PR0M0C0D35](https://camo.githubusercontent.com/5cb6615ac348692f9c9669d82e6bf3ef0acc2a1a7788d5b1ed51ef408b3eb4e7/687474703a2f2f692e696d67736166652e6f72672f633135313262622e6a7067)](https://github.com/trexology/promocodes)

[![Latest Stable Version](https://camo.githubusercontent.com/fbf8b9e149bd37bb675ce8fd0b018317515db441bd7cd2ed364fed9de152a784/68747470733a2f2f706f7365722e707567782e6f72672f747265786f6c6f67792f70726f6d6f636f6465732f76657273696f6e2e706e67)](https://packagist.org/packages/trexology/promocodes)[![Total Downloads](https://camo.githubusercontent.com/1f767b5e8eabbf7a40b45bfd8220aedbd867e2074aac9e09e563ca69e908c303/68747470733a2f2f706f7365722e707567782e6f72672f747265786f6c6f67792f70726f6d6f636f6465732f642f746f74616c2e706e67)](https://packagist.org/packages/trexology/promocodes)[![License](https://camo.githubusercontent.com/eabc555413291988ecffbfa4bbba78952b2080471bb2e1855db0bfd7673174cb/68747470733a2f2f706f7365722e707567782e6f72672f747265786f6c6f67792f70726f6d6f636f6465732f6c6963656e7365)](https://packagist.org/packages/trexology/promocodes)

Promotional Codes Generator for [Laravel 5.\*](http://laravel.com/)

Table of Contents
-----------------

[](#table-of-contents)

- [Installation](#installation)
    - [Composer](#composer)
    - [Laravel](#laravel)
- [Usage](#usage)
    - [Recomendations](#recomendations)
    - [Methods](#methods)
- [Config 'n Migration](#config-n-migration)
- [License](#license)

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

[](#installation)

### Composer

[](#composer)

Run composer command in your terminal.

```
composer require trexology/promocodes

```

### Laravel

[](#laravel)

Please read [Config 'n Migration](#config-n-migration) section first. It's requried to create **promocodes** table

Open `config/app.php` and find the `providers` key. Add `PromocodesServiceProvider` to the array.

```
Trexology\Promocodes\PromocodesServiceProvider::class
```

Find the `aliases` key and add `Facade` to the array.

```
'Promocodes' => Trexology\Promocodes\Facades\Promocodes::class
```

Usage
-----

[](#usage)

### Recomendations

[](#recomendations)

Run `php artisan make:model Promocode` and update `app/Promocode.php` as following:

```
/**
 * @var bool
 */
public $timestamps = false;

/**
 * @var array
 */
protected $fillable = [
	'code',
	'reward',
	'quantity',
  'is_used',
];
```

### Methods

[](#methods)

You can generate Promotional codes using `generate` method.

The only parameter is amount of codes to generate.

```
Promocodes::generate(5); // $amount = 1
```

- **$amount** int - number of promotional codes to be generated

This method will return array of codes with 5 element

---

You can generate and save codes instantly in your database using:

```
Promocodes::generateAndSave(5, 10.50); // $amount = 1, $reward = null
```

- **$amount** int - number of promotional codes to be generated
- **$reward** double - amount of reward of each promocodes

This will generate 5 codes and insert in your DB.

---

You can generate and save codes with the exact name in your database using:

```
Example:

Promocodes::generateCodeName("OFF20%", 0.2); // $reward = null (percentage discount)
Promocodes::generateCodeName("5SGDOFF", 5); // $reward = null (dollar discount)
```

- **$code** string - exact promotional code name to be generated
- **$reward** double - amount of reward of each promocodes

This will return false if code name already existed

---

Check code using method `check`.

Method returns boolean.

```
$valid = Promocodes::check('TEST-CODE'); // $promocode
```

- **$promocode** string - promotional code wich will be checked if issets

---

Laslty use code using method `apply`.

Method returns boolean.

```
$applied = Promocodes::apply('TEST-CODE', true); // $promocode, $hard_check = false
```

- **$promocode** string - promotional code wich will be checked if issets, and applied to current user
- **$hard\_check** boolean - if false or null, you will get only boolean value of checked promocode. If true you will get amount of reward as double or false.

If method returns false, code was already used or it wasn't valid

Config 'n Migration
-------------------

[](#config-n-migration)

Publish Promocodes config &amp; migration file using command:

```
php artisan vendor:publish

```

Created file `config\promocodes.php`. Inside you can change configuration as you wish. Created migration file, now you can simply run `php artisan migrate` and that's it, you will have promocodes table.

License
-------

[](#license)

Promocodes is an open-sourced laravel package licensed under the MIT license

TODO
----

[](#todo)

- Create migration for vendor publish

###  Health Score

33

—

LowBetter than 72% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity24

Limited adoption so far

Community14

Small or concentrated contributor base

Maturity63

Established project with proven stability

 Bus Factor1

Top contributor holds 76.2% 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 ~38 days

Recently: every ~22 days

Total

8

Last Release

3603d ago

Major Versions

0.1.5 → 1.02016-08-10

### Community

Maintainers

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

---

Top Contributors

[![zgabievi](https://avatars.githubusercontent.com/u/1515299?v=4)](https://github.com/zgabievi "zgabievi (48 commits)")[![gabiezur](https://avatars.githubusercontent.com/u/131362365?v=4)](https://github.com/gabiezur "gabiezur (7 commits)")[![Trexology](https://avatars.githubusercontent.com/u/3056348?v=4)](https://github.com/Trexology "Trexology (7 commits)")[![urakozz](https://avatars.githubusercontent.com/u/5797393?v=4)](https://github.com/urakozz "urakozz (1 commits)")

---

Tags

phplaravelpromo codecoupon codediscount code

### Embed Badge

![Health badge](/badges/trexology-promocodes/health.svg)

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

###  Alternatives

[gehrisandro/tailwind-merge-laravel

TailwindMerge for Laravel merges multiple Tailwind CSS classes by automatically resolving conflicts between them

341790.3k28](/packages/gehrisandro-tailwind-merge-laravel)[markwalet/nova-modal-response

A Laravel Nova asset for Modal responses on an action.

17818.7k](/packages/markwalet-nova-modal-response)[iteks/laravel-enum

A comprehensive Laravel package providing enhanced enum functionalities, including attribute handling, select array conversions, and fluent facade interactions for robust enum management in Laravel applications.

2518.6k](/packages/iteks-laravel-enum)[tomshaw/electricgrid

A feature-rich Livewire package designed for projects that require dynamic, interactive data tables.

119.2k](/packages/tomshaw-electricgrid)

PHPackages © 2026

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