Buffalo Eats Online API Documentation

ModuleService
in package

Service for managing feature modules and tier-based access control.

Maps subscription tiers to feature modules and provides access checks used by middleware, controllers, and views to enforce gating. Supports free tier, 14-day trial, and configurable module pricing.

Tags
author

J.J. Johnson visionquest716@gmail.com

copyright

2026 VisionQuestServices LLC

Table of Contents

Constants

ALL_MODULES  = ['reservations' => 'Reservations', 'analytics' => 'Analytics', 'coupons' => 'Coupons', 'promotions' => 'Promotions', 'mailing_list' => 'Mailing List', 'qr_codes' => 'QR Codes', 'staff' => 'Staff Management', 'themes' => 'Themes', 'advanced_orders' => 'Advanced Orders', 'api_access' => 'API Access', 'api_docs' => 'API Documentation (Swagger)', 'staff_scheduling' => 'Scheduling & Payroll', 'loyalty_rewards' => 'Loyalty & Rewards']
All available module names with display labels.
TIER_HIERARCHY  = ['free', 'basic', 'premium', 'enterprise']
Tier hierarchy — higher index includes all modules from lower tiers.
TIER_MODULES  = ['free' => [], 'basic' => [], 'premium' => ['reservations', 'analytics', 'coupons', 'promotions', 'mailing_list', 'qr_codes', 'loyalty_rewards'], 'enterprise' => ['reservations', 'analytics', 'coupons', 'promotions', 'mailing_list', 'qr_codes', 'loyalty_rewards', 'staff', 'themes', 'advanced_orders', 'api_access', 'api_docs', 'staff_scheduling']]
Modules included with each subscription tier.

Properties

$businessModel  : Business
$moduleModel  : BusinessModule

Methods

__construct()  : mixed
Initialize the module service.
calculateTierCost()  : float
Calculate the total monthly cost for a tier based on module pricing.
check()  : bool
Static convenience method for use in views.
disableModule()  : void
Manually disable a module for a business (admin override).
enableModule()  : void
Manually enable a module for a business (admin override).
extendTrial()  : bool
Admin: extend a trial by N days.
getAllModulePricing()  : array<string|int, mixed>
Get all module pricing records.
getEffectiveTier()  : string
Get the effective tier for a business (accounting for trial).
getEnabledModules()  : array<string|int, mixed>
Get all enabled modules for a business (tier defaults + overrides + trial).
getModulePricing()  : array<string|int, mixed>|null
Get pricing info for a specific module from the database.
getModulesForTier()  : array<string|int, mixed>
Get the list of modules included with a tier (including lower tiers).
getRequiredTier()  : string
Get the minimum tier required for a given module.
getTrialStatus()  : array<string|int, mixed>
Get trial status for a business.
isEnabled()  : bool
Check if a module is enabled for a business.
isInTrial()  : bool
Check if a business is currently in an active trial period.
startTrial()  : bool
Start a 14-day trial for a business.
syncModulesForTier()  : void
Sync module overrides when a subscription tier changes.
updateModulePricing()  : bool
Update module pricing.

Constants

ALL_MODULES

All available module names with display labels.

public mixed ALL_MODULES = ['reservations' => 'Reservations', 'analytics' => 'Analytics', 'coupons' => 'Coupons', 'promotions' => 'Promotions', 'mailing_list' => 'Mailing List', 'qr_codes' => 'QR Codes', 'staff' => 'Staff Management', 'themes' => 'Themes', 'advanced_orders' => 'Advanced Orders', 'api_access' => 'API Access', 'api_docs' => 'API Documentation (Swagger)', 'staff_scheduling' => 'Scheduling & Payroll', 'loyalty_rewards' => 'Loyalty & Rewards']

TIER_HIERARCHY

Tier hierarchy — higher index includes all modules from lower tiers.

public mixed TIER_HIERARCHY = ['free', 'basic', 'premium', 'enterprise']

TIER_MODULES

Modules included with each subscription tier.

public mixed TIER_MODULES = ['free' => [], 'basic' => [], 'premium' => ['reservations', 'analytics', 'coupons', 'promotions', 'mailing_list', 'qr_codes', 'loyalty_rewards'], 'enterprise' => ['reservations', 'analytics', 'coupons', 'promotions', 'mailing_list', 'qr_codes', 'loyalty_rewards', 'staff', 'themes', 'advanced_orders', 'api_access', 'api_docs', 'staff_scheduling']]

Higher tiers include all modules from lower tiers.

Properties

Methods

__construct()

Initialize the module service.

public __construct() : mixed

calculateTierCost()

Calculate the total monthly cost for a tier based on module pricing.

public calculateTierCost(string $tier) : float
Parameters
$tier : string

Tier name

Return values
float

Total monthly fee

check()

Static convenience method for use in views.

public static check(int $businessId, string $module) : bool
Parameters
$businessId : int

Business ID

$module : string

Module name

Return values
bool

disableModule()

Manually disable a module for a business (admin override).

public disableModule(int $businessId, string $module) : void
Parameters
$businessId : int

Business ID

$module : string

Module name

enableModule()

Manually enable a module for a business (admin override).

public enableModule(int $businessId, string $module) : void
Parameters
$businessId : int

Business ID

$module : string

Module name

extendTrial()

Admin: extend a trial by N days.

public extendTrial(int $businessId, int $days) : bool
Parameters
$businessId : int

Business ID

$days : int

Days to extend

Return values
bool

getAllModulePricing()

Get all module pricing records.

public getAllModulePricing() : array<string|int, mixed>
Return values
array<string|int, mixed>

getEffectiveTier()

Get the effective tier for a business (accounting for trial).

public getEffectiveTier(int $businessId) : string

During an active trial, businesses get premium-level access.

Parameters
$businessId : int

Business ID

Return values
string

Effective tier name

getEnabledModules()

Get all enabled modules for a business (tier defaults + overrides + trial).

public getEnabledModules(int $businessId) : array<string|int, mixed>
Parameters
$businessId : int

Business ID

Return values
array<string|int, mixed>

List of enabled module name strings

getModulePricing()

Get pricing info for a specific module from the database.

public getModulePricing(string $moduleKey) : array<string|int, mixed>|null
Parameters
$moduleKey : string

Module key

Return values
array<string|int, mixed>|null

getModulesForTier()

Get the list of modules included with a tier (including lower tiers).

public getModulesForTier(string $tier) : array<string|int, mixed>
Parameters
$tier : string

Subscription tier name

Return values
array<string|int, mixed>

List of module name strings

getRequiredTier()

Get the minimum tier required for a given module.

public getRequiredTier(string $module) : string
Parameters
$module : string

Module name

Return values
string

Tier name ('premium' or 'enterprise')

getTrialStatus()

Get trial status for a business.

public getTrialStatus(int $businessId) : array<string|int, mixed>
Parameters
$businessId : int

Business ID

Return values
array<string|int, mixed>

Trial info with keys: has_trial, is_active, ends_at, days_remaining

isEnabled()

Check if a module is enabled for a business.

public isEnabled(int $businessId, string $module) : bool

A module is enabled if:

  1. The business has an active trial (premium access), OR
  2. The business tier includes it by default, OR
  3. There is a manual override (is_enabled = 1) in business_modules

A manual disable override takes precedence over all.

Parameters
$businessId : int

Business ID

$module : string

Module name

Return values
bool

isInTrial()

Check if a business is currently in an active trial period.

public isInTrial(int $businessId) : bool
Parameters
$businessId : int

Business ID

Return values
bool

startTrial()

Start a 14-day trial for a business.

public startTrial(int $businessId) : bool
Parameters
$businessId : int

Business ID

Return values
bool

syncModulesForTier()

Sync module overrides when a subscription tier changes.

public syncModulesForTier(int $businessId, string $tier) : void

Removes all manual overrides so the new tier defaults take effect cleanly. Called by SubscriptionService on tier change.

Parameters
$businessId : int

Business ID

$tier : string

New subscription tier

updateModulePricing()

Update module pricing.

public updateModulePricing(int $id, array<string|int, mixed> $data) : bool
Parameters
$id : int

Module pricing ID

$data : array<string|int, mixed>

Fields to update

Return values
bool

        
On this page

Search results