laravel / pennant

A simple, lightweight library for managing feature flags.

Home Page:https://laravel.com/docs/10.x/pennant

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Feature activation

abdosaeedelhassan opened this issue · comments

Firstly thank you for a good package, i hope that in future be implemented inside laravel framework.
when creating new future without filter scope like next
Feature::define('administrator','administrator');
that create feature is active by default for all users, when i checked like next
Feature::active('administrator')
will give me (true), i suggest that the process be like next:
Feature::active('administrator'); // will be false Feature::activate('administrator'); // activate for current user Feature::active('administrator'); // will be true
This will give us ability to use this package also as roles and permissions.

Thanks.

Hey @abdosaeedelhassan,

When you create a feature definition:

Feature::define('administrator', 'administrator');

You are specifying that the default value of the administrator flag should be the string "administrator".

Note that features are not just boolean on / off, but may also contain "rich values" such as strings, arrays, etc.

For your particular usecase it sounds like you should instead do the following:

Feature::define('administrator', false);

This will mean that everyone will have the value false unless you otherwise activate the feature manually.

@timacdonald thank you for explanation, now i get it.