PHPackages                             ferdivemedya-wq/laravel-entitlements - 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. ferdivemedya-wq/laravel-entitlements

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

ferdivemedya-wq/laravel-entitlements
====================================

Simple and flexible entitlement management for Laravel applications, with support for plans, features, limits, and usage tracking.

10PHP

Since Jun 9Pushed yesterdayCompare

[ Source](https://github.com/ferdivemedya-wq/laravel-entitlements)[ Packagist](https://packagist.org/packages/ferdivemedya-wq/laravel-entitlements)[ RSS](/packages/ferdivemedya-wq-laravel-entitlements/feed)WikiDiscussions main Synced today

READMEChangelogDependenciesVersions (1)Used By (0)

[![Laravel Entitlements](assets/banner.png)](assets/banner.png)

Laravel Entitlements
====================

[](#laravel-entitlements)

[![Latest Version on Packagist](https://camo.githubusercontent.com/668fd509a6ee41abe07d8372d5d4441b9cb8a7950e421704b255f12a5df852dd/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6d6173746572697832312f6c61726176656c2d656e7469746c656d656e74732e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/masterix21/laravel-entitlements)[![Tests](https://camo.githubusercontent.com/f39caae28c12182b7d85868f434fbe79e2b4345210ba03c0d64ac151a04ae2a3/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f6d6173746572697832312f6c61726176656c2d656e7469746c656d656e74732f72756e2d74657374732e796d6c3f6272616e63683d6d61696e266c6162656c3d7465737473267374796c653d666c61742d737175617265)](https://github.com/masterix21/laravel-entitlements/actions/workflows/run-tests.yml)[![Total Downloads](https://camo.githubusercontent.com/413417affbde30f134ff2614929385a4e8c32d419f1619a318a26fdc25724235/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6d6173746572697832312f6c61726176656c2d656e7469746c656d656e74732e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/masterix21/laravel-entitlements)[![License: MIT](https://camo.githubusercontent.com/6c711032aff1ca0eb6b211aa6cb3649ce7fd64a7714e1181d4bb457f9680e7cf/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d677265656e2e7376673f7374796c653d666c61742d737175617265)](LICENSE.md)[![Sponsor](https://camo.githubusercontent.com/be1dd5d9c69e1311a76e872805c80fd792019d64e190a2fa30e854cb91db4888/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f73706f6e736f722d2545322539442541342d6666363962343f7374796c653d666c61742d737175617265266c6f676f3d676974687562)](https://github.com/sponsors/masterix21)

> If this package saves you time, please consider [**sponsoring my work on GitHub**](https://github.com/sponsors/masterix21/) — it directly funds maintenance and new features.

A flexible entitlement management system for Laravel applications. Define subscription plans, issue licenses to any model, and track consumption — slot-based or pool-based — with project-specific entitlement types injected via configuration.

Why
---

[](#why)

Every SaaS reinvents the same wheel: plans, plan items, licenses with start/end dates, usage tracking with two-phase release for some resources (a device that must confirm deactivation) and metered drain for others (a token pool). This package extracts that machinery so each project only declares the things that actually change: which entitlement types exist and how each one is consumed.

Features
--------

[](#features)

- **Polymorphic ownership** — any model with the `HasEntitlements` trait can hold licenses (workspace, team, user, tenant)
- **Plans catalog** — categorized plans with billing period (monthly/yearly), recurring or fixed-term, with translatable names
- **Plan items** — define how many slots of each type a plan grants; flexible items accept per-assignment overrides
- **Two consumption strategies out of the box**:
    - `SlotStrategy` — one usage per subject, with optional two-phase release (`Active → Releasing → Released`)
    - `PoolStrategy` — drainable counter across multiple licenses, FIFO by expiration
- **Project-specific type enum** — declare your own backed enum (e.g. `Device`, `AiTokens`, `Seat`, `ApiCall`) and map each case to a strategy
- **Domain events** — `PlanAssigned`, `LicenseConsumed`, `ReleaseRequested`, `LicenseReleased`, `LicenseReconciled`
- **Reconciliation** — recompute `slot_used` from actual open usages, useful after manual intervention or drift
- **Optional Filament v5 admin UI** — plug-in for Plans/Plan Categories management and a `LicensesRelationManager` for the subscriber resource

Requirements
------------

[](#requirements)

- PHP `^8.2`
- Laravel `^11 || ^12 || ^13`
- `spatie/laravel-package-tools`
- `spatie/laravel-translatable` (for translatable plan names)

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

[](#installation)

```
composer require masterix21/laravel-entitlements
```

Publish the config and migrations:

```
php artisan vendor:publish --tag="laravel-entitlements-config"
php artisan vendor:publish --tag="laravel-entitlements-migrations"
php artisan migrate
```

Configuration
-------------

[](#configuration)

`config/entitlements.php` after publishing:

```
return [
    // Required: the backed enum that implements EntitlementType
    'type_enum' => \App\Enums\LicenseType::class,

    // Override models if you want to extend them
    'models' => [
        'plan_category'  => \LucaLongo\LaravelEntitlements\Models\PlanCategory::class,
        'plan'           => \LucaLongo\LaravelEntitlements\Models\Plan::class,
        'plan_item'      => \LucaLongo\LaravelEntitlements\Models\PlanItem::class,
        'license'        => \LucaLongo\LaravelEntitlements\Models\License::class,
        'license_usage'  => \LucaLongo\LaravelEntitlements\Models\LicenseUsage::class,
    ],

    'table_names' => [
        'plan_categories' => 'entitlement_plan_categories',
        'plans'           => 'entitlement_plans',
        'plan_items'      => 'entitlement_plan_items',
        'licenses'        => 'entitlement_licenses',
        'license_usages'  => 'entitlement_license_usages',
    ],
];
```

The `type_enum` is validated at boot: if the class doesn't exist or doesn't implement `EntitlementType`, an `InvalidEntitlementTypeException` is thrown.

Usage
-----

[](#usage)

### 1. Declare your entitlement types

[](#1-declare-your-entitlement-types)

Create a backed enum that implements `EntitlementType` and maps each case to a strategy:

```
