PatoLab’s persistence layer is built on Laravel’s Eloquent ORM and the standard migration system. For local development and automated testing the default driver is SQLite (a file-based database stored atDocumentation Index
Fetch the complete documentation index at: https://mintlify.com/lerichardv/patolab-platform/llms.txt
Use this file to discover all available pages before exploring further.
database/database.sqlite), which requires zero configuration. Staging and production deployments should target MySQL or PostgreSQL, configured through the DB_* variables in your .env file. All three engines are supported without any code changes — only the DB_CONNECTION value and the matching host/credential variables differ.
Supported Databases
| Environment | Driver | DB_CONNECTION |
|---|---|---|
| Local development | SQLite (file) | sqlite |
| CI / automated tests | SQLite (:memory:) | sqlite |
| Staging / Production | MySQL | mysql |
| Staging / Production | PostgreSQL | pgsql |
.env:
Running Migrations
PatoLab ships with a comprehensive set of migrations that build the entire schema from scratch. Always run migrations before first use and after pulling updates.Fresh install (wipe, migrate, and seed)
Drop all tables, re-run every migration in order, and load all seed data. Use this when setting up a clean local environment:
Seeder Classes
Runningphp artisan db:seed (or php artisan migrate:fresh --seed) invokes DatabaseSeeder, which calls the following seeders in order:
| # | Seeder class | What it populates |
|---|---|---|
| 1 | PermissionsSeeder | System permissions |
| 2 | RolesSeeder | User roles and permission assignments |
| 3 | SettingsSeeder | Application-wide settings |
| 4 | DepartmentSeeder | Geographic departments |
| 5 | MunicipalitySeeder | Municipalities linked to departments |
| 6 | SpecimenTypeSeeder | Specimen types and examinations |
| 7 | ReferrerSeeder | Referring physicians / entities |
| 8 | LocationSeeder | Lab locations |
| 9 | SequenceSeeder | Specimen sequence counters |
| 10 | StorageSeeder | Storage locations |
| 11 | ProductSeeder | Inventory products / reagents |
| 12 | CaiRangeSeeder | CAI (invoice control) ranges |
| 13 | PrioritySeeder | Kanban board priorities |
| 14 | SpecimenCategorySeeder | Specimen categories |
| 15 | WorkOrderTypeSeeder | Work-order type definitions |
| 16 | CustomerSeeder | Sample customer records |
| 17 | BanksSeeder | Bank reference list |
| 18 | UsersSeeder | Demo admin users |
Audit Logging
PatoLab models that require a full change history use theAuditable trait (app/Traits/Auditable.php). Attaching the trait to any Eloquent model automatically writes a row to the audit_log table for every create, update, and delete event.
What is tracked per event:
| Event | Columns stored |
|---|---|
create | Every attribute on the new record (old_value = null, new_value = <value>) |
update | Only the changed columns — old_value holds the previous value, new_value the new one |
delete | A single row: column = deleted_at, old_value = active, new_value = deleted |
audit_log:
audit_session_code— a unique 24-character code grouping all rows from a single save operationaction—create|update|deletetable— the model’s database tablerow_id— the primary key of the affected recordcolumn— the specific column that changedold_value/new_value— cast to string (arrays and objects are JSON-encoded)user— the authenticated user’s ID at the time of the change
created_at, updated_at, deleted_at, password, remember_token.
Audit entries are only created when a user is authenticated. Artisan commands or queue jobs running without an authenticated session will not produce audit records.
Key Migration Files
The table below maps the most significant migration files to the domain concepts they establish:Core application tables
Core application tables
| Migration file | Table(s) created / altered | Purpose |
|---|---|---|
0001_01_01_000000_create_users_table.php | users, password_reset_tokens, sessions | Authentication and session management |
0001_01_01_000001_create_cache_table.php | cache, cache_locks | Database-backed cache driver |
0001_01_01_000002_create_jobs_table.php | jobs, job_batches, failed_jobs | Database queue infrastructure |
2026_05_08_230814_create_customers_table.php | customers | Patient / customer profiles |
2026_05_11_170346_create_specimen_type_table.php | specimen_type | Specimen type catalogue |
2026_05_11_170423_create_specimen_type_examination_table.php | specimen_type_examination | Examinations belonging to a specimen type |
2026_05_12_214531_create_specimen_table.php | specimen | Central specimen entity |
2026_05_12_210027_create_specimen_category_table.php | specimen_category | Categories grouping specimen types |
2026_05_13_133345_create_audit_log_table.php | audit_log | Immutable audit trail |
2026_05_19_135200_create_priorities_table.php | priorities | Kanban board priority lanes |
2026_05_19_144344_priorities_specimens_order_table.php | priorities_specimens_order | Per-priority card ordering for Kanban |
2026_05_19_171558_create_cai_ranges_table.php | cai_ranges | Fiscal invoice control ranges (CAI) |
2026_05_20_154346_create_invoices_table.php | invoices | Billing invoices |
2026_05_20_155852_create_credits_table.php | credits | Credit notes linked to invoices |
2026_05_12_220218_create_inventory_table.php | inventory | Product stock levels per storage location |
2026_05_12_220541_create_specimen_products_table.php | specimen_products | Products consumed by a specimen |
2026_05_12_225745_create_inventory_movements_table.php | inventory_movements | Stock movement log |
2026_05_12_142422_create_sequences_table.php | sequences | Auto-increment sequence counters |
2026_05_27_192304_create_settings_table.php | settings | Key-value application configuration |
2026_05_28_125509_create_roles_table.php | roles | RBAC roles |
2026_05_28_125553_create_permissions_table.php | permissions | Granular permissions |
2026_06_04_163351_create_specimen_reports_table.php | specimen_reports | Collaborative pathology reports (Yjs/TipTap) |
2026_06_09_154618_create_specimen_type_templates_table.php | specimen_type_templates | Report templates per specimen type |
2026_06_10_185823_create_rentals_table.php | rentals | Equipment rental invoicing |
2026_06_17_194200_create_user_commission_rules_table.php | user_commission_rules | Commission rule definitions per user |
2026_06_17_195147_create_user_commissions_table.php | user_commissions | Calculated commissions per specimen |
2026_06_30_191219_create_work_order_types_table.php | work_order_types | Work-order type catalogue |
2026_06_30_191250_create_work_orders_table.php | work_orders | Lab work orders |
