Features are the individual capabilities or limits offered to users. You can create them using the Feature model with several configuration options:
- Consumable Features: Set
consumable => true. These have a limited number of uses or amounts. You can define periodicity_type (e.g., PeriodicityType::Day) and periodicity (e.g., 1) to make them renew automatically. - Non-Consumable Features: Set
consumable => false. These simply grant access to a capability (e.g., custom-domain). - Postpaid Features: Set
postpaid => true. Users can use these even if they don't have enough charges, allowing you to bill them later. - Quota Features: Set
quota => true. These represent a constant value (like disk storage) that you manually sync using setConsumedQuota().
// Consumable, renewing daily
$deployMinutes = Feature::create([
'consumable' => true,
'name' => 'deploy-minutes',
'periodicity_type' => PeriodicityType::Day,
'periodicity' => 1,
]);
// Non-consumable
$customDomain = Feature::create([
'consumable' => false,
'name' => 'custom-domain',
]);
// Postpaid
$cpuUsage = Feature::create([
'consumable' => true,
'postpaid' => true,
'name' => 'cpu-usage',
]);
// Quota
$storage = Feature::create([
'consumable' => true,
'quota' => true,
'name' => 'storage',
]);