PHPackages                             adeela/user-discounts - 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. adeela/user-discounts

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

adeela/user-discounts
=====================

A Laravel package for user-level discounts

v1.0.0(9mo ago)02PHPPHP ^7.4|^8.0

Since Sep 28Pushed 8mo ago1 watchersCompare

[ Source](https://github.com/adeelagit/Laravel-user-discount-package)[ Packagist](https://packagist.org/packages/adeela/user-discounts)[ RSS](/packages/adeela-user-discounts/feed)WikiDiscussions main Synced today

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

Laravel User Discounts Package
==============================

[](#laravel-user-discounts-package)

A Laravel 8+ package to manage **user-level discounts** with deterministic stacking, usage caps, and audit logging.

---

✨ Features
----------

[](#-features)

- Assign and revoke discounts to specific users
- Validate user discount eligibility
- Apply discounts with stacking and rounding logic
- Enforce per-user usage limits
- Log and audit discount usage
- Fire events on discount assignment, revocation, and application

---

🧩 Installation
--------------

[](#-installation)

1. **Install via Composer**

    ```
    composer require adeela/user-discounts
    ```
2. **Register Service Provider (if not auto-discovered)**

    In `config/app.php`:

    ```
    'providers' => [
        Adeela\UserDiscounts\UserDiscountsServiceProvider::class,
    ],
    ```
3. **Publish Config File**

    ```
    php artisan vendor:publish --provider="Adeela\UserDiscounts\UserDiscountsServiceProvider" --tag="config"
    ```

    This creates `config/user-discounts.php`.
4. **Run Migrations (if provided)**

    ```
    php artisan migrate
    ```

---

⚙️ Configuration
----------------

[](#️-configuration)

Sample `config/user-discounts.php`:

```
```php
return [
    'stacking_order' => 'highest_first',
    'max_percentage_cap' => 50,
    'rounding' => 'round',
];
```

```

🧠 Usage Examples
----------------

[](#-usage-examples)

### 1. Create a Discount

[](#1-create-a-discount)

```
use Adeela\UserDiscounts\Models\Discount;

$discount = Discount::create([
    'code' => 'Save20',
    'name' => 'Save 20%',
    'type'       => 'percentage',
    'value'      => 20,
    'active'     => 1,
    'starts_at'  => now()->subDay(),
    'ends_at'    => now()->addDay(),
]);
```

### 2. Assign Discount to a User

[](#2-assign-discount-to-a-user)

```
$service = new \Adeela\UserDiscounts\Services\DiscountService();

$user = User::find(1);
$discount = Discount::find(34);

$service->assign($user, $discount);
```

### 4. Apply Discount

[](#4-apply-discount)

```
$service = new \Adeela\UserDiscounts\Services\DiscountService();
$amount = 100;
$orderRef = 'ORDER-12345';
$user = User::find(1);

$finalAmount = $service->apply($user, $amount, $orderRef);
dd("Final amount after discounts: {$finalAmount}");
```

### 5. Revoke Discount

[](#5-revoke-discount)

```
$service = new \Adeela\UserDiscounts\Services\DiscountService();

$user = User::find(1);
$discount = Discount::find(34);

$service->revoke($user, $discount);
```

---

🔔 Events
--------

[](#-events)

EventDescription`DiscountAssigned`Triggered when a discount is assigned`DiscountRevoked`Triggered when a discount is revoked`DiscountApplied`Triggered when a discount is applied---

🧪 Testing
---------

[](#-testing)

```
vendor/bin/phpunit
```

---

###  Health Score

28

—

LowBetter than 52% of packages

Maintenance58

Moderate activity, may be stable

Popularity2

Limited adoption so far

Community4

Small or concentrated contributor base

Maturity41

Maturing project, gaining track record

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

278d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/169344928?v=4)[Adeela](/maintainers/adeelagit)[@adeelagit](https://github.com/adeelagit)

### Embed Badge

![Health badge](/badges/adeela-user-discounts/health.svg)

```
[![Health](https://phpackages.com/badges/adeela-user-discounts/health.svg)](https://phpackages.com/packages/adeela-user-discounts)
```

###  Alternatives

[psalm/plugin-laravel

Psalm plugin for Laravel

3355.3M346](/packages/psalm-plugin-laravel)[renatomarinho/laravel-page-speed

Laravel Page Speed

2.5k1.7M11](/packages/renatomarinho-laravel-page-speed)[illuminate/pagination

The Illuminate Pagination package.

12234.1M1.0k](/packages/illuminate-pagination)[illuminate/pipeline

The Illuminate Pipeline package.

9349.2M282](/packages/illuminate-pipeline)[illuminate/redis

The Illuminate Redis package.

8314.6M375](/packages/illuminate-redis)[spatie/laravel-export

Create a static site bundle from a Laravel app

674146.0k6](/packages/spatie-laravel-export)

PHPackages © 2026

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