Skip to main content

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 through JurisdictionManager or Installation::jurisdiction(). HR modules must not add if (country === ...) branches.
  • Sector policy lives in app/Sectors/ plus the jurisdiction's Config/sector.php and is resolved through SectorManager. HR modules must not add if (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 BelongsToTenant and TenantContext. Every new HR table carries company_id and is scoped by the trait, with deliberate withoutTenant() 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​

AreaPath
Shared HR modelsapp/Models/ (OrganizationUnit, Location, CostCenter, PositionAssignment, Document, WorkflowDefinition, AuditEvent, …)
Government modelsapp/Jurisdictions/Philippines/Government/Models/
Government servicesapp/Jurisdictions/Philippines/Government/Services/
Government admin UIapp/Jurisdictions/Philippines/Government/Admin/ and the feature-pack menu
Private recruitment/employment/separationapp/Models/, app/Services/Recruitment, app/Services/Employment, app/Services/Separation
Workforce and talentapp/Services/Attendance, app/Services/Performance, app/Services/Learning
Retirementapp/Services/Retirement, app/Models/Retirement*, app/Models/ExternalClaimTracking
Complianceapp/Services/Compliance, app/Models/Compliance*
Analyticsapp/Services/Analytics, app/Livewire/Admin/Reports/WorkforceAnalytics.php
Admin resourcesapp/Livewire/Admin/Resources/
Domain actionsapp/Livewire/Admin/Actions/{Government,PrivateSector,Workforce,Retirement,Compliance}/
Employee portalapp/Livewire/Portal/ and resources/views/livewire/portal/
Migrationsdatabase/migrations/2026_11_27_*
Teststests/Feature/Hr/

Data model by phase​

Shared foundation​

  • organization_units (hierarchy, type, parent), locations, cost_centers.
  • positions enriched 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_events and 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 PlantillaItem and ServiceRecord, wired through config/government.php.

Private​

  • job_requisitions, extended job_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 on timesheets.
  • 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​

ServiceResponsibility
Organization\OrganizationUnitServiceUnit creation, hierarchy moves, cycle prevention
Organization\PositionAssignmentServiceEffective-dated occupancy, closing prior assignment, history
Documents\DocumentServiceUpload, immutable versions, classification, acknowledgments, download
Workflow\WorkflowEngineDefinition activation, instance start, task completion, decisions, delegation
Workflow\ApproverResolverResolve approver scopes and reporting lines
Workflow\WorkflowDefinitionValidatorReject invalid step graphs
Hr\AuditLoggerAppend-only audit entries
Government\PlantillaServicePlantilla version publishing and item lifecycle
Government\QualificationScreeningServiceQualification standard screening
Government\AppointmentServiceAppointment state machine, documents, assumptions
Government\PersonnelActionServicePromotion/transfer/detail actions and occupancy
Recruitment\RecruitmentServiceRequisition pipeline, offers, hire conversion, onboarding
Employment\EmploymentServiceEmployment start, probation, regularization, contract changes
Leave\PrivateLeavePolicyServicePrivate leave policy resolution
Separation\SeparationServiceClearance, final settlement inputs, effective separation
Attendance\AttendanceCorrectionServiceCorrection request, decision, apply-as-new-punch
Attendance\TimesheetApprovalServiceSubmit, approve/reject, payroll lock
Performance\PerformanceServiceCycles, goals, reviews, ratings, finalization
Learning\LearningServiceCourses, sessions, capacity-aware enrollment, certifications
Retirement\RetirementEligibilityServiceAge/service/plan-effective-date snapshot
Retirement\RetirementServiceCase lifecycle, calculations, review, claims
Compliance\ComplianceRegistrySources, rules, version review/approval, as-of resolution
Analytics\WorkforceAnalyticsTenant-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 displayUsing when the value needs a resource method.
  • BelongsTo form keys are relation names (form.employee), not foreign keys.
  • Read-only resources override canCreateResource(), authorizedToCreate(), authorizedToUpdate(), and authorizedToDelete().
  • 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.

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:

AreaActions
GovernmentApprovePlantillaVersion, ScreenQualification, TransitionAppointment, RecordAppointmentAssumption, RecordCscAction, AdvancePersonnelAction
PrivateTransitionRequisition, PublishVacancy, ScreenApplication, IssueJobOffer, RespondToJobOffer, HireApplicant, StartEmployment, RecordRegularizationDecision, InitiateSeparation, CompleteClearanceTask, TransitionSeparation, RecordFinalSettlement
WorkforceDecideAttendanceCorrection, ManageTimesheetApproval, ActivatePerformanceCycle, StartPerformanceReview, FinalizePerformanceReview, CompleteTrainingEnrollment
RetirementOpenRetirementCase, ManageRetirementCase, ReviewRetirementCalculation, ManageExternalClaim
ComplianceRegisterComplianceRule, 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\ModuleFlags is the only way to read or write the state. It uses Feature::globally(), so the value never depends on the signed-in user, and falls back to "enabled" when the features table has not been migrated yet.
  • A deployment can pin modules from .env: HR_MODULES_DISABLED and HR_MODULES_ENABLED take comma-separated module keys (see config/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 and features:toggle refuse runtime changes.
  • App\Providers\FeatureFlagServiceProvider defines every flag as enabled by default.
  • Enforcement is centralised: ResourceRegistry::resolve() returns 404 for a disabled module's resources, Navigation drops tagged sections/groups/items (and resources whose $module is off), and the module middleware guards employee portal routes.
  • The Settings → Features page (App\Livewire\Admin\Settings\Settings) and the features:list / features:toggle commands are the operator surfaces. Toggles are audit-logged as feature.toggled.

To add a module:

  1. Add a case to App\Enums\HrModule with a label and description.
  2. Set public static ?HrModule $module = HrModule::YourModule; on each resource it owns.
  3. Tag the admin menu section in config/admin.php with 'module' => 'your-module'.
  4. 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 in WorkflowEngine.
  • Immutable models throw LogicException on update/delete. Service methods that need to transition an immutable record lock it via withoutTenant() 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\BelongsToTenant and company_id.
  • Services that must act across the global scope (locking, jobs, console commands) use withoutTenant() deliberately and then restore context.
  • Any table without company_id must be scoped through a tenant-owned parent. Compliance rule versions originally lacked company_id; migration 2026_11_27_001020 adds it so the resource cannot leak another tenant's configurations.
  • Console commands use App\Console\Concerns\RunsForTenants and 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:

  • RefreshDatabase with SQLite in memory.
  • Company::factory() plus User::factory()->forCompany($company) and actingAs($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​

  1. Extend the unit type constants on App\Models\OrganizationUnit.
  2. Update OrganizationUnitService validation and the resource Select.
  3. Add a migration only if the new level needs new columns; keep parent_id hierarchy intact.
  4. Add a test in tests/Feature/Hr/OrganizationStructureTest.php.

Add a government module​

  1. Create the model and service under app/Jurisdictions/Philippines/Government/.
  2. Add the resource under the government Admin/Resources folder and register it in GovernmentFeaturePack::adminMenu().
  3. Add the migration with guarded Schema::hasTable/hasColumn calls.
  4. Add service and resource tests under tests/Feature/Hr/Government/.

Add a retirement formula type​

  1. Choose a new inert JSON shape (for example {"type":"career_salary","rate":0.02}).
  2. Add the branch to RetirementService::benefitAmounts() and include the computed values in outputs.
  3. Keep the rule version in rule_version and never auto-approve the result.
  4. Add a fixture/practice test to tests/Feature/Hr/Retirement/RetirementServiceTest.php.
  5. Document the shape in the retirement plan field help text and the release notes.

Add a compliance rule​

  1. Register the authority in Compliance → Sources.
  2. Register the rule in Compliance → Rules with code, sector, effective dates, and inert JSON configuration.
  3. Submit the version for review, then approve it.
  4. 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​

  1. Create or update a workflow_definitions record with steps and approver scopes.
  2. Validate it through WorkflowDefinitionValidator.
  3. Start an instance from the domain service with subject_type/subject_id.
  4. Resolve approvers with ApproverResolver; keep due dates on tasks.
  5. 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.