Skip to main content

Employee Management Module

Overview

The Employee Management module is the foundational module of the HRMS. Every other module (KPI, Probation, Leave, Attendance) builds on top of employee records.

Scope

FeatureStatus
Employee CRUD✅ Implemented
Profile Picture✅ Implemented
Attachments✅ Implemented
Reporting Hierarchy✅ Implemented
CSV Import✅ Implemented
CSV Export✅ Implemented
Bulk Actions🔜 Planned

Data Model

Core Tables

employees (id, employee_number, first_name, last_name, ...)
├── has one → user (id, name, email, password)
├── belongs to → entity (company)
├── belongs to → department
├── belongs to → employee (reports_to)
├── has many → emergency_contacts
├── has many → dependents
├── has many → qualifications (polymorphic: work_experiences, education, skills, languages, licenses)
├── has many → attachments (polymorphic, categorized by section)
└── has many → kpi_evaluations

Key Relationships

RelationshipTypeDescription
Employee → UserOne-to-OneEvery employee has a linked system user account
Employee → EntityMany-to-OneEmployee belongs to one company
Employee → DepartmentMany-to-OneEmployee belongs to one department
Employee → Employee (Reports To)Self-referencingCreates management chain
Department → ManagersMany-to-ManyVia department_manager pivot
Department → Team LeadsMany-to-ManyVia department_team_lead pivot

Business Rules

Activity Status + Lifecycle Validation

Activity StatusAllowed Lifecycles
ActiveProbationary, Confirmed
InactiveResigned, Terminated

Invalid combinations (e.g., Active + Terminated) are rejected at the request validation layer.

Employee Number

  • Automatically generated when an employee is created
  • Format: ENTITYNAME-NNN (e.g., HAYO-001, SLICK-002)
  • The prefix is derived from the entity name (uppercased, non-alphanumeric characters removed)
  • The sequence number is zero-padded to 3 digits and increments per entity
  • Uses database-level locking (lockForUpdate) to prevent race conditions
  • Cannot be changed after creation (enforced by prohibited validation rule)
  • During CSV import, the column is optional — auto-generated if blank or missing

Work Email

  • Must be unique across the entire system
  • Used as the login email for the linked user account

Deletion Policy

Employee records are never deleted. They are deactivated by setting activity_status = Inactive and updating the lifecycle to Resigned or Terminated.

Architecture

Backend Components

ComponentPathPurpose
Modelapp/Models/Employee.phpEloquent model with relationships and scopes
Controllerapp/Http/Controllers/EmployeeController.phpCRUD endpoints
Number Generatorapp/Services/EmployeeNumberGenerator.phpAuto-generates employee numbers per entity
Serviceapp/Services/EmployeeService.phpBusiness logic
Import Serviceapp/Services/EmployeeImportService.phpCSV import processing
Policyapp/Policies/EmployeePolicy.phpAuthorization rules
Resourceapp/Http/Resources/EmployeeResource.phpAPI response transformation
Requestsapp/Http/Requests/Employee/Validation rules per action

Frontend Components

ComponentPathPurpose
List Pageapp/dashboard/employees/page.tsxEmployee listing with search, filter, export
Create Pageapp/dashboard/employees/create/page.tsxMulti-tab creation wizard
Detail Pageapp/dashboard/employees/[id]/page.tsxEmployee profile view
Edit Pageapp/dashboard/employees/[id]/edit/page.tsxMulti-tab edit form

Visibility Scoping

Employee visibility is controlled by the EmployeePolicy based on the user's role:

// Simplified visibility logic
Admin / HR → all employees
Manager → all employees (read-only)
TeamLead → employees in led departments + own record
Employee → own record only

API Endpoints

MethodEndpointDescription
GET/api/employeesList employees (paginated, filterable)
POST/api/employeesCreate employee
GET/api/employees/{id}Get employee details
PUT/api/employees/{id}Update employee
POST/api/employees/{id}/profile-pictureUpload profile picture
DELETE/api/employees/{id}/profile-pictureRemove profile picture
GET/api/employees/{id}/attachmentsList attachments
POST/api/employees/{id}/attachmentsUpload attachment
DELETE/api/employees/{id}/attachments/{aid}Delete attachment
GET/api/employees/export/csvExport CSV
POST/api/employees/importImport from CSV

2026-03 UX Updates

  • Employee personal details UI now uses Salutation + First Name + Last Name order in create/edit form.
  • Salutation is persisted in the existing middle_name field for backward-compatible storage (no schema migration).
  • Employee attachments now provide Preview for supported files (images/PDF) plus download.