Skip to main content

Checking Features

Entitlements represent the features a subscriber can access based on their active plan. The Entitlements facade provides a clean API for checking feature access and limits.

Basic feature check

use Pixelworxio\Subscribd\Facades\Entitlements;

if (Entitlements::for($user)->allows('exports')) {
    // User's plan includes the 'exports' feature
}

Checking a limit

When a feature is a numeric limit rather than a boolean, use limit():
$maxProjects = Entitlements::for($user)->limit('projects');
// Returns int — e.g. 5, or null for unlimited

Checking a value

Some features hold a string value rather than a count. Compare them with allows():
// Feature defined as: 'support' => 'priority'
Entitlements::for($user)->allows('support', 'priority'); // true
Entitlements::for($user)->allows('support', 'enterprise'); // false

Plan feature configuration

Features are declared in config/subscribd.php under each plan:
'plans' => [
    'starter' => [
        'features' => [
            'projects'  => 5,         // limit of 5
            'exports'   => false,     // not available
            'api'       => true,      // available
            'support'   => 'email',   // string value
        ],
    ],
    'pro' => [
        'features' => [
            'projects'  => null,      // unlimited
            'exports'   => true,      // available
            'api'       => true,
            'support'   => 'priority',
        ],
    ],
],

Gate integration

Register a gate for each feature to use Laravel’s built-in @can directive and Gate::allows() calls:
// AppServiceProvider::boot()
use Pixelworxio\Subscribd\Facades\Entitlements;
use Illuminate\Support\Facades\Gate;

Gate::define('use-exports', function ($user) {
    return Entitlements::for($user)->allows('exports');
});
@can('use-exports')
    <a href="{{ route('exports.create') }}">Export data</a>
@endcan

Aborting on missing entitlement

abort_unless(Entitlements::for($user)->allows('api'), 403, 'Upgrade required.');

Next steps