Two Laravel devs that won't disappear on you. Finally! Hire Joel and Aaron from No Compromises.

Manage Subscription Plans and Entitlements in Laravel with Laravel Entitlements

Last updated on by

Manage Subscription Plans and Entitlements in Laravel with Laravel Entitlements image

Laravel Entitlements tackles one of the more involved problems in SaaS development: modeling what a subscriber is allowed to do, how much of it they can use, and what happens when they hit a limit or switch plans.

Rather than rolling your own entitlement logic, this package gives you a structured approach built around plans, licenses, and consumption tracking. Here's a quick overview of what the package covers:

  • Slot-based and pool-based consumption — slot strategies track one usage per subject (e.g., a specific device or seat), while pool strategies drain a shared counter (e.g., AI tokens or API credits)
  • Polymorphic ownership — any Eloquent model can act as a subscriber by adding the HasEntitlements trait, making it straightforward to scope entitlements to teams, workspaces, or individual users
  • Plan catalog with billing options — plans support monthly/yearly billing cycles and can be configured as recurring or fixed-term, with items that allow per-assignment quantity overrides
  • Domain events — the package dispatches events like LicenseConsumed, ReleaseRequested, and LicenseReconciled, giving you integration points for billing webhooks, background jobs, or audit logging
  • Optional Filament v5 admin panel — a ready-made management interface for plans, categories, and licenses that can be dropped into an existing Filament project

Defining Entitlement Types

The package uses a PHP backed enum to define what kinds of entitlements exist in your app and which strategy each one uses. This means the consumption logic is tied to your domain vocabulary rather than generic configuration:

enum LicenseType: string implements EntitlementType
{
case Device = 'device';
case AiTokens = 'ai_tokens';
case Seat = 'seat';
 
public function strategy(): EntitlementStrategy
{
return match ($this) {
self::Device => new SlotStrategy(twoPhase: true),
self::AiTokens => new PoolStrategy(),
self::Seat => new SlotStrategy(),
};
}
}

The twoPhase: true option on the Device case is worth noting — it splits release into two steps (requestRelease() then confirmRelease()), which is useful when you need an external process (like revoking a device token) to complete before the slot is freed.

Consuming and Checking Entitlements

Once a plan is assigned to a subscriber, consuming an entitlement is a single method call:

// Slot-based: tie usage to a specific subject
Entitlements::consume($workspace, LicenseType::Seat, $user);
 
// Pool-based: drain a set amount from the shared counter
Entitlements::consume($workspace, LicenseType::AiTokens, $usage, amount: 1500);

Checking availability before consuming is just as direct:

Entitlements::can($workspace, LicenseType::AiTokens, 1500); // bool
Entitlements::available($workspace, LicenseType::AiTokens); // remaining capacity

When capacity runs out, the package throws a NoEntitlementAvailableException, which you can catch and handle at the controller or middleware level.

Plan Transitions

Switching a subscriber between plans is handled through changePlan(), which supports both immediate switches and end-of-period transitions. The package validates the transition before persisting it, so subscribers won't lose capacity for usages already in flight when a downgrade is applied.

Installation

Install via Composer:

composer require masterix21/laravel-entitlements

Then publish and run the migrations:

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

The package requires PHP 8.2+ and Laravel 11 or higher. The optional Filament integration requires Filament v5.

You can find the full documentation and source code on GitHub.

Paul Redmond photo

Staff writer at Laravel News. Full stack web developer and author.

Cube

Laravel Newsletter

Join 40k+ other developers and never miss out on new tips, tutorials, and more.

image
Acquaint Softtech

Hire Laravel developers with AI expertise at $20/hr. Get started in 48 hours.

Visit Acquaint Softtech
Kirschbaum logo

Kirschbaum

Providing innovation and stability to ensure your web application succeeds.

Kirschbaum
Acquaint Softtech logo

Acquaint Softtech

Acquaint Softtech offers AI-ready Laravel developers who onboard in 48 hours at $3000/Month with no lengthy sales process and a 100 percent money-back guarantee.

Acquaint Softtech
Harpoon: Next generation time tracking and invoicing logo

Harpoon: Next generation time tracking and invoicing

The next generation time-tracking and billing software that helps your agency plan and forecast a profitable future.

Harpoon: Next generation time tracking and invoicing
PhpStorm logo

PhpStorm

The go-to PHP IDE with extensive out-of-the-box support for Laravel and its ecosystem.

PhpStorm
SerpApi logo

SerpApi

Access real-time search engine results through a simple API—no more scraping headaches! Use it for AI applications, SEO tools, product research, travel information, and more

SerpApi
Tinkerwell logo

Tinkerwell

The must-have code runner for Laravel developers. Tinker with AI, autocompletion and instant feedback on local and production environments.

Tinkerwell
Lucky Media logo

Lucky Media

Get Lucky Now - the ideal choice for Laravel Development, with over a decade of experience!

Lucky Media
SaaSykit: Laravel SaaS Starter Kit logo

SaaSykit: Laravel SaaS Starter Kit

SaaSykit is a Multi-tenant Laravel SaaS Starter Kit that comes with all features required to run a modern SaaS. Payments, Beautiful Checkout, Admin Panel, User dashboard, Auth, Ready Components, Stats, Blog, Docs and more.

SaaSykit: Laravel SaaS Starter Kit
Shift logo

Shift

Running an old Laravel version? Instant, automated Laravel upgrades and code modernization to keep your applications fresh.

Shift
Laravel Cloud logo

Laravel Cloud

Easily create and manage your servers and deploy your Laravel applications in seconds.

Laravel Cloud
No Compromises logo

No Compromises

Joel and Aaron, the two seasoned devs from the No Compromises podcast, are now available to hire for your Laravel project. ⬧ Flat rate of $9500/mo. ⬧ No lengthy sales process. ⬧ No contracts. ⬧ 100% money back guarantee.

No Compromises

The latest

View all →
Laravel Fluent Validation: An Object-Oriented Rule Builder image

Laravel Fluent Validation: An Object-Oriented Rule Builder

Read article
Moat: A Security Review for Your GitHub Account image

Moat: A Security Review for Your GitHub Account

Read article
Laravel Paper: A Flat-File Eloquent Driver image

Laravel Paper: A Flat-File Eloquent Driver

Read article
Simple Feature Flags for Laravel with Laravel Toggle image

Simple Feature Flags for Laravel with Laravel Toggle

Read article
Manage Laravel Cloud Deployments Inside PhpStorm image

Manage Laravel Cloud Deployments Inside PhpStorm

Read article
Piper: Laravel-Style Array and String Helpers for PHP's Pipe Operator image

Piper: Laravel-Style Array and String Helpers for PHP's Pipe Operator

Read article