DEF STUDIO srl

Need help with Laravel and web development?

Hire one of our experts for your projects.

We build tailored products, websites and platforms — with care for UX, performance and maintainability.

Booking open for Q4 — limited slots

Feature Check

Feature Check

In code feature can be checked in multiple ways for the logged user:

Check if enabled

if(AppFeature::multi_language->active()){
    //.. multi language specific code
}

Check if disabled

if(AppFeature::multi_language->active()){
    //.. multi language specific code
}

Enforced

AppFeature::impersonate->enforce(); //throws a 403 exception if not active

Feature Check for a given scope

Each check can be applied to a scope different from the logged user:

$user = User::find(42);

if(AppFeature::multi_language->active($user)){
    //.. multi language specific code
}

if(AppFeature::multi_language->active($user)){
    //.. multi language specific code
}

AppFeature::impersonate->enforce($user); //throws a 403 exception if not active

Multiple feature checks

This package can check for multiple feature at once as well:

All Active

if(AppFeature::areAllActive([AppFeature::multi_language, AppFeature::welcome_email])){
    //.. 
}

Some Active

if(AppFeature::someAreActive([AppFeature::multi_language, AppFeature::welcome_email])){
    //.. 
}

All Inactive

if(AppFeature::areAllInactive([AppFeature::multi_language, AppFeature::welcome_email])){
    //.. 
}

Some Inactive

if(AppFeature::someAreInactive([AppFeature::multi_language, AppFeature::welcome_email])){
    //.. 
}

Suggest a change
Last updated 26 April 2024