Skip to main content

HR modules

OpenHR PH ships as a small core plus optional HR modules. Core HR — employees, organisation structure, attendance, leave, payroll and reports — is always on. The optional modules can be switched on only when a team uses them, so a new installation opens with a focused menu instead of every screen.

HrModule ── category, dependencies
│
ModuleCatalogue ── definitions, dependents, resources, cycle check
│
ModulePreset ── Core, Essentials, Talent, Compliance, Full
│
ModuleFlags ── Pennant global flags + .env pins + configured state
│
├─ Navigation (module AND group access AND company hide AND permission)
├─ ResourceRegistry (404, not just hidden)
├─ GlobalSearchService
└─ Dashboard metrics

Key files​

ConcernFile
Module keys, categories, dependenciesapp/Enums/HrModule.php
Module categoriesapp/Enums/ModuleCategory.php
Bundles offered at setupapp/Enums/ModulePreset.php
Definitions and dependency graphapp/Support/Features/ModuleCatalogue.php
Switch reads/writes and configured stateapp/Support/Features/ModuleFlags.php
Per-group narrowingapp/Support/Features/ModuleAccess.php
Advisory usage signalapp/Support/Features/ModuleUsage.php
Menu filteringapp/Livewire/Admin/Support/Navigation.php
Resource routing gateapp/Livewire/Admin/Support/ResourceRegistry.php
Setup pageapp/Livewire/Admin/Setup/Modules.php
Navigation pinsapp/Livewire/Admin/Setup/NavigationPreferences.php
Settings toggle pageapp/Livewire/Admin/Settings/Settings.php

Visibility rule​

An admin screen is visible only when all of these are true:

  1. The module is enabled for the installation.
  2. The user's group allows the module (an empty groups.module_access allows every enabled module).
  3. The company has not hidden the menu entry (companies.hidden_menu).
  4. The entry's can permission key is granted to the group.

Navigation, ResourceRegistry, the command palette and dashboard cards all use the same rule. Hiding a module therefore hides the menu entry, removes it from search, and returns 404 from its URLs. No data is deleted, and switching the module back on restores access to the same records.

Dependencies​

Dependencies live on the enum:

public function dependsOn(): array
{
return match ($this) {
self::Separation, self::Retirement => [self::Employment],
default => [],
};
}
  • Enabling a module also enables every prerequisite.
  • Disabling a module that enabled modules depend on throws ModuleDependencyException unless a cascade is requested.
  • ModuleCatalogue::hasCycle() is covered by a test; keep the graph acyclic.

Choosing modules​

Three entry points write the same flags:

# Fresh install: Core only
php artisan openhr:install --sector=Private --country=PH --modules=core

# A bundle or a fine-grained list
php artisan openhr:install --sector=Private --country=PH --modules=essentials
php artisan openhr:install --sector=Private --country=PH --modules=recruitment,performance

# After installation
php artisan modules:preset full
php artisan modules:toggle recruitment disable
php artisan modules:toggle employment disable --cascade
php artisan modules:list
php artisan modules:usage --days=90

In the admin workspace, use Settings → HR Modules (the setup page) or Settings → Features. Only a company owner or platform administrator can change the installation selection; other administrators can review it. The .env lists HR_MODULES_DISABLED and HR_MODULES_ENABLED pin a module for the whole deployment and always win over stored values.

The Features page also offers Hide unused, which disables modules that have had no recorded usage in the idle window. It skips a prerequisite when one of its dependents is still in use, and it never deletes records.

Installation::KEY_MODULES_CONFIGURED_AT records whether an admin has chosen the module set. Installations created before this setting existed keep every module on until they run setup, so existing deployments do not lose menus on upgrade.

Adding a module​

  1. Add a case to HrModule with a category and, if needed, dependencies.
  2. Tag each resource with public static ?HrModule $module = HrModule::YourModule;.
  3. Add the menu section or items to config/admin.php with 'module' => 'your-module'.
  4. Add portal routes with the module:your-module middleware.
  5. Add the module to any relevant ModulePreset bundles.
  6. Run php artisan modules:list and php artisan test tests/Feature/Hr.

Adding per-company hiding​

Menu entries are keyed by resource key, link path or a slug of the label, and whole sections use a slug of the section label. Companies → Hidden menu items stores the keys on companies.hidden_menu. Hiding is presentation only: it never changes module state, permissions or data.

Testing the matrix​

The module suite lives in tests/Feature/Hr:

TestCovers
ModuleCatalogueTestCategories, dependencies, dependents, presets, cascade
ModuleFeaturesTestInstallation switches, .env pinning, resources, portal
ModuleSetupTestSetup page, --modules, Core default
ModuleNavigationTestEmpty sections, company hiding, pins, palette
ModuleGroupAccessTestGroup narrowing, 404s, dashboard cards
ModuleUsageTestRecording, throttling, idle detection

phpunit.xml forces HR_MODULES_DISABLED and HR_MODULES_ENABLED to empty so a developer .env cannot pin modules during tests.