Seeders
The CPR backend uses 38 seeder classes to populate the database with initial data and test records.
Running Seeders
# Run all seeders
php artisan db:seed
# Run a specific seeder
php artisan db:seed --class=RoleSeeder
# Fresh migrate and seed
php artisan migrate:fresh --seedSeeding Order
The DatabaseSeeder runs seeders in this order to satisfy foreign key dependencies:
1. BranchSeeder # Clinic branches
2. RoleSeeder # Roles and permissions
3. UserSeeder # Staff users
4. InsuranceSeeder # Insurance plans
5. MedicineSeeder # Medicine reference data
6. PharmacyItemFormSeeder # Dosage forms
7. PharmacyItemSeeder # Pharmacy products
8. StockAvailableUnitSeeder # Stock units
9. StockAvailableSeeder # Initial stock levels
10. ProcedureSeeder # Medical procedures
11. BillingItemSeeder # Billable items
12. SupplierSeeder # Suppliers
13. PurchaseOrderStatusSeeder # PO status types
14. PaymentMethodSeeder # Payment options
15. PatientSeeder # Test patients
16. DoctorRoleSeeder # Doctor specializations
17. DoctorSeeder # Doctor profiles
18. SurgeryLocationSeeder # OR locations
19. SurgeryScheduleSeeder # Surgery schedules
20. BranchServiceSeeder # Services per branch
21. BranchServiceCounterSeeder # Queue counters
22. BranchServiceUserSeeder # Staff-service assignments
23. PurchaseOrderSeeder # Sample POs
24. DeliverySeeder # Sample deliveries
25. TransactionSeeder # Sample transactions
26. StockMovementSeeder # Stock movement historyKey Seeders
BranchSeeder
Creates 3 clinic branches:
| Branch | Code | Address |
|---|---|---|
| Main Clinic | MAIN | 123 Healthcare Avenue |
| Downtown Branch | DWTN | 456 Central Street |
| North Side Clinic | NORTH | 789 Northern Road |
Each branch has operating hours and service configuration stored in the settings JSON column.
RoleSeeder
Creates 7 roles with specific permissions:
| Role | Key Permissions |
|---|---|
admin | Full system access including admin.access |
doctor | Patient care, consultations, medical records |
nurse | Patient care, vitals, basic records |
receptionist | Appointments, registration, queue management |
pharmacist | Pharmacy, medication dispensing |
lab_technician | Laboratory, test processing |
billing_staff | Billing, accounts, transactions |
Permissions follow the {module}.{action} pattern (e.g., patients.create, pharmacy.read) with 40+ permissions across modules: users, roles, branches, patients, appointments, medical-records, consultations, laboratory, pharmacy, billing, reports, settings, vitals, inventory, admin.
UserSeeder
Creates 11 test users with role and branch assignments:
| User | Role | Branch | Username |
|---|---|---|---|
| Admin User | admin | MAIN | admin |
| Dr. Sarah Chen | doctor | MAIN | dr.chen |
| Dr. Michael Torres | doctor | DWTN | dr.torres |
| Dr. Emily Watson | doctor | NORTH | dr.watson |
| Maria Santos | nurse | MAIN | nurse.santos |
| Anna Rivera | nurse | DWTN | nurse.rivera |
| Juan Cruz | receptionist | MAIN | recep.cruz |
| Lisa Reyes | receptionist | DWTN | recep.reyes |
| Carlos Garcia | pharmacist | MAIN | pharm.garcia |
| Mark Johnson | lab_technician | MAIN | lab.johnson |
| Grace Lee | billing_staff | MAIN | billing.lee |
Default Password
All test users have the password: password
Address Seeders
Philippine geographic data is loaded from CSV files in database/seeders/csv/:
- Regions, Provinces, Municipalities, Barangays, Zipcodes
- Used for patient address lookup and validation
Creating New Seeders
php artisan make:seeder ExampleSeederGuidelines
- Add the new seeder to
DatabaseSeeder.phpin the correct dependency order - Use model factories where possible for test data
- For reference/lookup data, use
insertOrIgnoreto be idempotent - Always position the seeder call after its foreign key dependencies