HR platform modules
This page is the developer reference for the HR capabilities. It covers where the code lives, how the modules fit together, and how to extend them without breaking sector or jurisdiction boundaries.
Architectural boundaries
The platform follows the existing repository rules:
- Country law lives in
app/Jurisdictions/<Country>and is resolved throughJurisdictionManagerorInstallation::jurisdiction(). HR modules must not addif (country === ...)branches. - Sector policy lives in
app/Sectors/plus the jurisdiction'sConfig/sector.phpand is resolved throughSectorManager. HR modules must not addif (government)branches in payroll or UI code. - Philippine statutory calculators stay in
App\Jurisdictions\Philippines\Statutory. The government HR module (App\Jurisdictions\Philippines\Government) is policy and records, not statutory payroll. - Tenancy is enforced by
BelongsToTenantandTenantContext. Every new HR table carriescompany_idand is scoped by the trait, with deliberatewithoutTenant()calls inside services that need to lock or read across the tenant boundary. - Audit is append-only. High-risk records (
AuditEvent,WorkflowDecision,AttendanceCorrectionDecision,TimesheetApproval) throw on update and delete.
Code map
| Area | Path |
|---|---|
| Shared HR models | app/Models/ (OrganizationUnit, Location, CostCenter, PositionAssignment, Document, WorkflowDefinition, AuditEvent, …) |
| Government models | app/Jurisdictions/Philippines/Government/Models/ |
| Government services | app/Jurisdictions/Philippines/Government/Services/ |
| Government admin UI | app/Jurisdictions/Philippines/Government/Admin/ and the feature-pack menu |
| Private recruitment/employment/separation | app/Models/, app/Services/Recruitment, app/Services/Employment, app/Services/Separation |
| Workforce and talent | app/Services/Attendance, app/Services/Performance, app/Services/Learning |
| Retirement | app/Services/Retirement, app/Models/Retirement*, app/Models/ExternalClaimTracking |
| Compliance | app/Services/Compliance, app/Models/Compliance* |
| Analytics | app/Services/Analytics, app/Livewire/Admin/Reports/WorkforceAnalytics.php |
| Admin resources | app/Livewire/Admin/Resources/ |
| Domain actions | app/Livewire/Admin/Actions/{Government,PrivateSector,Workforce,Retirement,Compliance}/ |
| Employee portal | app/Livewire/Portal/ and resources/views/livewire/portal/ |
| Migrations | database/migrations/2026_11_27_* |
| Tests | tests/Feature/Hr/ |
Data model by phase
Shared foundation
organization_units(hierarchy, type, parent),locations,cost_centers.positionsenriched with requirements, job descriptions, effective-dated assignments, reporting relationships, and employment changes.documents,document_versions,document_access_logs,document_acknowledgments.workflow_definitions,workflow_instances,workflow_tasks,workflow_decisions,workflow_delegations.audit_eventsand database notifications.
Government
plantilla_versions,plantilla_items.appointment_records, appointment documents/actions/assumptions,personnel_actions.- HRMPSB committees, members, and deliberations.
- App subclasses of the package
PlantillaItemandServiceRecord, wired throughconfig/government.php.
Private
job_requisitions, extendedjob_vacancies,applications,application_documents,screening_results,interviews,interview_evaluations,assessments,selection_recommendations,job_offers.employments,employment_contracts,probationary_reviews,regularization_decisions,onboarding_checklists,onboarding_tasks,leave_policy_rules.separation_cases,clearance_templates,clearance_tasks,final_settlements.
Workforce and talent
attendance_corrections,attendance_correction_decisions,timesheet_approvals, plus approval columns ontimesheets.performance_cycles,performance_goals,performance_reviews,performance_ratings,development_plans.training_courses,training_sessions,training_enrollments,employee_certifications.
Retirement and compliance
retirement_plans,retirement_cases,retirement_calculations,retirement_documents,external_claim_tracking.compliance_sources,compliance_rules,compliance_rule_versions.
Service catalogue
| Service | Responsibility |
|---|---|
Organization\OrganizationUnitService | Unit creation, hierarchy moves, cycle prevention |
Organization\PositionAssignmentService | Effective-dated occupancy, closing prior assignment, history |
Documents\DocumentService | Upload, immutable versions, classification, acknowledgments, download |
Workflow\WorkflowEngine | Definition activation, instance start, task completion, decisions, delegation |
Workflow\ApproverResolver | Resolve approver scopes and reporting lines |
Workflow\WorkflowDefinitionValidator | Reject invalid step graphs |
Hr\AuditLogger | Append-only audit entries |
Government\PlantillaService | Plantilla version publishing and item lifecycle |
Government\QualificationScreeningService | Qualification standard screening |
Government\AppointmentService | Appointment state machine, documents, assumptions |
Government\PersonnelActionService | Promotion/transfer/detail actions and occupancy |
Recruitment\RecruitmentService | Requisition pipeline, offers, hire conversion, onboarding |
Employment\EmploymentService | Employment start, probation, regularization, contract changes |
Leave\PrivateLeavePolicyService | Private leave policy resolution |
Separation\SeparationService | Clearance, final settlement inputs, effective separation |
Attendance\AttendanceCorrectionService | Correction request, decision, apply-as-new-punch |
Attendance\TimesheetApprovalService | Submit, approve/reject, payroll lock |
Performance\PerformanceService | Cycles, goals, reviews, ratings, finalization |
Learning\LearningService | Courses, sessions, capacity-aware enrollment, certifications |
Retirement\RetirementEligibilityService | Age/service/plan-effective-date snapshot |
Retirement\RetirementService | Case lifecycle, calculations, review, claims |
Compliance\ComplianceRegistry | Sources, rules, version review/approval, as-of resolution |
Analytics\WorkforceAnalytics | Tenant-scoped workforce metrics |
Admin UI conventions
Resources live in App\Livewire\Admin\Resources and implement:
fields(Request $request)— form and table columns;cards,filters,lenses,actions— optional arrays;- static
$model,$group,$search,$with,$sector,$jurisdiction,$module.
Key rules:
- A resource class name that matches its model short name must alias the model import
(
use App\Models\Document as DocumentModel). - Computed field closures bind to the model, not the resource. Use
displayUsingwhen the value needs a resource method. BelongsToform keys are relation names (form.employee), not foreign keys.- Read-only resources override
canCreateResource(),authorizedToCreate(),authorizedToUpdate(), andauthorizedToDelete(). - Use explicit short index names for long MySQL composite indexes.
Government resources set $sector = 'Government' and $jurisdiction = 'PH'; private resources set
$sector = 'Private'. Shared HR resources leave both unset so they appear for either sector.
Resources that belong to an installable HR module set $module to the matching App\Enums\HrModule
case, for example public static ?HrModule $module = HrModule::Retirement;. See
Feature flags.
Menu registration
Shared and private menus are sections in config/admin.php. Government menus come from the feature
pack (App\Jurisdictions\Philippines\Government\GovernmentFeaturePack::adminMenu()), so the same
resource can appear only when the installation is Government. A section that belongs to an HR module
declares the module key ('module' => 'retirement'), so the whole section disappears when the module
is switched off.
Actions
Actions extend App\Livewire\Admin\Actions\Action and declare fields() plus handle(). Scope an action
with onlyOnIndexToolbar(), onlyOnTableRow(), onlyBulk(), onlyOnDetail(), or onlyOnIndex().
Important actions:
| Area | Actions |
|---|---|
| Government | ApprovePlantillaVersion, ScreenQualification, TransitionAppointment, RecordAppointmentAssumption, RecordCscAction, AdvancePersonnelAction |
| Private | TransitionRequisition, PublishVacancy, ScreenApplication, IssueJobOffer, RespondToJobOffer, HireApplicant, StartEmployment, RecordRegularizationDecision, InitiateSeparation, CompleteClearanceTask, TransitionSeparation, RecordFinalSettlement |
| Workforce | DecideAttendanceCorrection, ManageTimesheetApproval, ActivatePerformanceCycle, StartPerformanceReview, FinalizePerformanceReview, CompleteTrainingEnrollment |
| Retirement | OpenRetirementCase, ManageRetirementCase, ReviewRetirementCalculation, ManageExternalClaim |
| Compliance | RegisterComplianceRule, ManageComplianceRuleVersion |
Feature flags
Each module can be switched off for the whole installation with a Laravel Pennant flag. The module
catalogue lives in App\Enums\HrModule; every case maps to a feature named hr.<module>
(hr.recruitment, hr.employment, hr.separation, hr.workforce, hr.performance, hr.learning,
hr.retirement, hr.compliance).
App\Support\Features\ModuleFlagsis the only way to read or write the state. It usesFeature::globally(), so the value never depends on the signed-in user, and falls back to "enabled" when thefeaturestable has not been migrated yet.- A deployment can pin modules from
.env:HR_MODULES_DISABLEDandHR_MODULES_ENABLEDtake comma-separated module keys (seeconfig/features.php). An environment override always wins over the stored value, and the disabled list wins when a module appears in both.ModuleFlags::locked()reports those pins so the Settings page andfeatures:togglerefuse runtime changes. App\Providers\FeatureFlagServiceProviderdefines every flag as enabled by default.- Enforcement is centralised:
ResourceRegistry::resolve()returns 404 for a disabled module's resources,Navigationdrops tagged sections/groups/items (and resources whose$moduleis off), and themodulemiddleware guards employee portal routes. - The Settings → Features page (
App\Livewire\Admin\Settings\Settings) and thefeatures:list/features:togglecommands are the operator surfaces. Toggles are audit-logged asfeature.toggled.
To add a module:
- Add a case to
App\Enums\HrModulewith a label and description. - Set
public static ?HrModule $module = HrModule::YourModule;on each resource it owns. - Tag the admin menu section in
config/admin.phpwith'module' => 'your-module'. - Guard any portal routes with
->middleware('module:your-module').
Workflow and audit integration
- Domain services call
AuditLogger::record()after state changes. Pass the subject model and compact before/after arrays; never include file bytes, tokens, or secrets. - Workflow definitions are data. Validation happens in
WorkflowDefinitionValidator; activation and execution happen inWorkflowEngine. - Immutable models throw
LogicExceptionon update/delete. Service methods that need to transition an immutable record lock it viawithoutTenant()and update the status columns they own. - Retirement and compliance approvals follow the same pattern: calculations and rule versions start as drafts, are reviewed, and become immutable once approved.
Tenancy rules
- New tenant tables use
App\Models\Concerns\BelongsToTenantandcompany_id. - Services that must act across the global scope (locking, jobs, console commands) use
withoutTenant()deliberately and then restore context. - Any table without
company_idmust be scoped through a tenant-owned parent. Compliance rule versions originally lackedcompany_id; migration2026_11_27_001020adds it so the resource cannot leak another tenant's configurations. - Console commands use
App\Console\Concerns\RunsForTenantsand iterate companies explicitly.
Testing
Run the narrowest suite first:
php artisan test --compact tests/Feature/Hr
vendor/bin/pint --dirty --format agent
The complete suite at the end of the release:
php artisan test --compact
# 834 passed, 3 skipped, 4249 assertions
Testing conventions used by these modules:
RefreshDatabasewith SQLite in memory.Company::factory()plusUser::factory()->forCompany($company)andactingAs($user)to establish the tenant.- Factories for employees, timesheets, positions, and users; direct model creation for the new HR records until factories are added.
- Service-level tests for state machines and calculations, resource tests for registry/field wiring, and portal tests for employee ownership.
- Immutability is asserted with
expect(fn () => $model->update(...))->toThrow(LogicException::class).
Extension recipes
Add a new organization type or unit level
- Extend the unit type constants on
App\Models\OrganizationUnit. - Update
OrganizationUnitServicevalidation and the resourceSelect. - Add a migration only if the new level needs new columns; keep
parent_idhierarchy intact. - Add a test in
tests/Feature/Hr/OrganizationStructureTest.php.
Add a government module
- Create the model and service under
app/Jurisdictions/Philippines/Government/. - Add the resource under the government
Admin/Resourcesfolder and register it inGovernmentFeaturePack::adminMenu(). - Add the migration with guarded
Schema::hasTable/hasColumncalls. - Add service and resource tests under
tests/Feature/Hr/Government/.
Add a retirement formula type
- Choose a new inert JSON shape (for example
{"type":"career_salary","rate":0.02}). - Add the branch to
RetirementService::benefitAmounts()and include the computed values inoutputs. - Keep the rule version in
rule_versionand never auto-approve the result. - Add a fixture/practice test to
tests/Feature/Hr/Retirement/RetirementServiceTest.php. - Document the shape in the retirement plan field help text and the release notes.
Add a compliance rule
- Register the authority in Compliance → Sources.
- Register the rule in Compliance → Rules with code, sector, effective dates, and inert JSON configuration.
- Submit the version for review, then approve it.
- Consumers resolve it by code and as-of date:
use App\Services\Compliance\ComplianceRegistry;
$resolved = app(ComplianceRegistry::class)->resolve('OT_PREMIUM', 'Private', $payDate);
$configuration = $resolved['configuration'];
Resolution throws a ValidationException when no approved rule is effective or when candidates
conflict. Do not fall back to a silent default in compliance-sensitive code.
Add a workflow-backed HR process
- Create or update a
workflow_definitionsrecord with steps and approver scopes. - Validate it through
WorkflowDefinitionValidator. - Start an instance from the domain service with
subject_type/subject_id. - Resolve approvers with
ApproverResolver; keep due dates on tasks. - Render pending tasks through the shared Approvals inbox.
API and integration boundaries
The release does not add a token-authenticated public API. The intended contract, when an auth package is approved, is:
/api/v1/retirement/cases— list and inspect retirement cases scoped to the authenticated tenant./api/v1/compliance/rules— resolved, approved configurations as of a requested date./api/v1/performance/reviews— read-only review status for integrations.
Requirements for that work:
- scoped authorization per route, mirroring the policies used by the admin;
- tenant and organization isolation;
- request validation and pagination/filtering;
- rate limits and idempotency keys for sensitive create/approve operations;
- consistent error format and audit events;
- versioning/deprecation policy and no mass assignment of protected status fields.
Until then, integration happens through:
- External claim tracking for GSIS/SSS, with reference, status, submission, release, and notes.
- Retirement calculations with recorded inputs, outputs, and rule versions.
- Documents attached to a case with classification and access logging.
- Reminders for due cases, stale claims, expiring certifications, and expiring compliance rules.
- CSV exports through the existing report/export patterns where a controlled extract is needed.