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(7mo ago)02PHPPHP ^7.4|^8.0

Since Sep 28Pushed 7mo 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 1mo ago

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

29

—

LowBetter than 60% of packages

Maintenance64

Regular maintenance activity

Popularity2

Limited adoption so far

Community4

Small or concentrated contributor base

Maturity40

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

225d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/422444d9346810f0996a484fd5a636ee03fac5047ab4080c0ed202eb3ee8151f?d=identicon)[adeelagit](/maintainers/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

[barryvdh/laravel-ide-helper

Laravel IDE Helper, generates correct PHPDocs for all Facade classes, to improve auto-completion.

14.9k123.0M685](/packages/barryvdh-laravel-ide-helper)[orchestra/canvas

Code Generators for Laravel Applications and Packages

21017.2M158](/packages/orchestra-canvas)[illuminate/pipeline

The Illuminate Pipeline package.

9446.6M213](/packages/illuminate-pipeline)[illuminate/pagination

The Illuminate Pagination package.

10532.5M861](/packages/illuminate-pagination)[spatie/laravel-pjax

A pjax middleware for Laravel 5

513371.8k11](/packages/spatie-laravel-pjax)[spatie/laravel-mix-preload

Add preload and prefetch links based your Mix manifest

169176.0k2](/packages/spatie-laravel-mix-preload)

PHPackages © 2026

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