PHPackages                             megaads/coupon-utils - 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. megaads/coupon-utils

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

megaads/coupon-utils
====================

Utilities for coupons

v1.1.7(5y ago)0510MITPHPPHP &gt;=5.6.4

Since Oct 24Pushed 5y ago6 watchersCompare

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

READMEChangelogDependenciesVersions (12)Used By (0)

Cài đặt:

```
composer require megaads/coupon-utils

```

Sau khi cài đặt xong thì cấu hình Service Provider class vào file `app.php` trong thư mục `config` của Laravel như sau:

```
Megaads\CouponUtils\CouponUtilsServiceProvider::class,

```

Sau đó thì chạy câu lệnh sau để tạo file cấu hình:

```
php artisan vendor:publish --provider="Megaads\CouponUtils\CouponUtilsServiceProvider" --tag=config --force

```

Sau khi chạy lệnh thì file cấu hình được tạo sẽ có nội dung như sau:

```
return [
    'free_shipping' => [
        'text' => ['free(.*)shipping'],
        'regex' => [
            'default' => '/#text/i'
        ],
        'value' => [
            'default' => ''
        ]
    ],
    'percent' => [
        'text' => ['off'],
        'regex' => [
            'default' => '/(\d+)% #text/i'
        ],
        'value' => [
            'default' => '#value%'
        ]
    ],
    'amount' => [
        'text' => ['off'],
        'regex' => [
            'default' => '/\$(\d+) #text/i'
        ],
        'value' => [
            'default' => '$#value'
        ]
    ],
];

```

Sau khi sửa file cấu hình xong thì chạy lệnh sau để clear cache:

```
php artisan config:cache

php artisan cache:clear

```

Thêm cái này vào 'aliases' =&gt; \[\] trong file app.php

```
'CouponUtils' => Megaads\CouponUtils\CouponUtils::class,

```

Rồi gọi cái này để lấy coupon promotion type :

```
$couponType = CouponUtils::detectCouponType($titleOfCoupon);

```

Hoặc gọi theo kiểu cũ không dùng file cấu hình ở trên:

```
$couponType = CouponUtils::getCouponType($titleOfCoupon);

```

Return trả về kiểu kiểu như sau

```
$retval = [
    'type' => 'deal',
    'value' => '',
];

```

Trong đó type có thể là : 'deal', 'percent', 'amout', 'free\_shipping'

Value có thể là : '', '30', ...

###  Health Score

28

—

LowBetter than 54% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity12

Limited adoption so far

Community12

Small or concentrated contributor base

Maturity59

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 58.8% 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 ~33 days

Recently: every ~39 days

Total

11

Last Release

2058d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/72ad425c743522a807fd15e2a7b0ada9c2a2127ecca76fbef37cf9292022006a?d=identicon)[megaads-vn](/maintainers/megaads-vn)

---

Top Contributors

[![bachnx23](https://avatars.githubusercontent.com/u/7134491?v=4)](https://github.com/bachnx23 "bachnx23 (10 commits)")[![quanbka](https://avatars.githubusercontent.com/u/13042109?v=4)](https://github.com/quanbka "quanbka (6 commits)")[![tuananhzippy](https://avatars.githubusercontent.com/u/13558393?v=4)](https://github.com/tuananhzippy "tuananhzippy (1 commits)")

### Embed Badge

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

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

###  Alternatives

[ishanvyas22/asset-mix

Asset Mix plugin for CakePHP

3375.4k2](/packages/ishanvyas22-asset-mix)[prgayman/laravel-zatca

Laravel package a helper to Generate the QR code and signed it for ZATCA E-invoicing

2926.9k1](/packages/prgayman-laravel-zatca)[ducks-project/spl-types

Polyfill Module for SplType PHP extension. This extension aims at helping people making PHP a stronger typed language and can be a good alternative to scalar type hinting. It provides different typehandling classes as such as integer, float, bool, enum and string

1032.4k](/packages/ducks-project-spl-types)

PHPackages © 2026

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