Overview
Seeders populate the database with demo data for development and testing. They create sample companies, users, customers, inventory, and transactions.Running Seeders
Run All Seeders
Run Specific Seeder
Fresh Migration with Seeding
Seeder Execution Order
Seeders run in the following order (defined inDatabaseSeeder.php):
- CompanySeeder - Creates demo companies
- UserSeeder - Creates test users
- SubscriptionSeeder - Creates company subscriptions
- OperationalDataSeeder - Creates customers, equipment, and orders
- InventorySeeder - Creates inventory items
- BillingSeeder - Creates billing documents
Seeder Files
All seeders are located indatabase/seeders/.
DatabaseSeeder.php
Main seeder that orchestrates all other seeders. File:database/seeders/DatabaseSeeder.php
Execution Order:
CompanySeeder
Creates two demo companies for testing multi-tenancy. File:database/seeders/CompanySeeder.php
Companies Created:
1. ElectroFix Cliente Demo
Main demo company for client simulation. Data:- Name: ElectroFix Cliente Demo
- Owner: Carlos Mendoza
- Email: [email protected]
- Phone: +52 55 1000 1000
- Tax ID: RFC123456AB1
- Billing Email: [email protected]
- Billing Phone: +52 55 1000 1001
- Address: Av. Reforma 100, CDMX, CDMX, 06600, MX
- Currency: MXN
- VAT: 16%
- Notes: “Empresa demo principal para entorno local.”
2. ElectroFix Developer Lab
Development and testing company. Data:- Name: ElectroFix Developer Lab
- Owner: ElectroFix Platform Team
- Email: [email protected]
- Phone: +52 55 2000 2000
- Tax ID: RFCDEV1234X9
- Billing Email: [email protected]
- Billing Phone: +52 55 2000 2001
- Address: Innovation Park 42, Monterrey, NL, 64000, MX
- Currency: MXN
- VAT: 16%
- Notes: “Empresa fija para pruebas de developer.”
updateOrCreate() to avoid duplicates on re-seeding.
UserSeeder
Creates three test users with different roles and permissions. File:database/seeders/UserSeeder.php
Users Created:
1. Admin User
Credentials:- Email: [email protected]
- Password: password123
- Name: Admin ElectroFix
- Company: ElectroFix Cliente Demo
- Role: admin
- Active: true
- Access Billing: true
- Access Inventory: true
2. Worker User
Credentials:- Email: [email protected]
- Password: password123
- Name: Worker ElectroFix
- Company: ElectroFix Cliente Demo
- Role: worker
- Active: true
- Access Billing: false
- Access Inventory: true
3. Developer User
Credentials:- Email: [email protected]
- Password: password123
- Name: Developer ElectroFix
- Company: ElectroFix Developer Lab
- Role: developer
- Active: true
- Access Billing: true
- Access Inventory: true
All passwords are hashed using Laravel’s bcrypt. The plain text “password123” is shown here for testing purposes only.
SubscriptionSeeder
Creates active subscriptions for both demo companies. File:database/seeders/SubscriptionSeeder.php
Subscriptions Created:
1. ElectroFix Cliente Demo Subscription
Data:- Plan: pro
- Status: active
- Starts: Beginning of current month
- Ends: End of next month
- Billing Cycle: monthly
- User Limit: 25 users
2. ElectroFix Developer Lab Subscription
Data:- Plan: developer_test
- Status: active
- Starts: Beginning of current month
- Ends: One year from now
- Billing Cycle: yearly
- User Limit: 999 users
OperationalDataSeeder
Creates customers, equipment, and repair orders with AI diagnostics. File:database/seeders/OperationalDataSeeder.php
Data Created:
Customers (3 total)
For ElectroFix Cliente Demo:
-
Empresa Norte
- Email: [email protected]
- Phone: +52 55 3000 1000
- Address: CDMX, México
-
Cadena Sur
- Email: [email protected]
- Phone: +52 55 3000 2000
- Address: Puebla, México
For ElectroFix Developer Lab:
- Developer Lab Client
- Email: [email protected]
- Phone: +52 55 5555 5555
- Address: Monterrey, México
Equipment (3 total)
For Cliente Demo:
-
Washing Machine
- Serial: EF-LAV-001
- Customer: Empresa Norte
- Type: Lavadora
- Brand: Samsung
- Model: WF45R6100
-
Refrigerator
- Serial: EF-REF-002
- Customer: Cadena Sur
- Type: Refrigerador
- Brand: LG
- Model: GR-X24
For Developer Lab:
- Microwave
- Serial: DEV-TEST-001
- Customer: Developer Lab Client
- Type: Microondas
- Brand: Whirlpool
- Model: WMX20
Orders (2 total)
Order 1: Washing Machine Diagnostic
Basic Info:- Company: ElectroFix Cliente Demo
- Customer: Empresa Norte
- Equipment: Samsung WF45R6100 (EF-LAV-001)
- Technician: Operador A
- Status: diagnostic
- Estimated Cost: $1,500 MXN
- Potential Causes:
- Falla en fuente de alimentación
- Posible desgaste mecánico
- Estimated Time: 3-5 horas
- Suggested Parts:
- Tarjeta electrónica
- Rodamientos
- Technical Advice: “Verificar voltajes y continuidad antes de cambiar componentes.”
Order 2: Refrigerator Quote
Basic Info:- Company: ElectroFix Cliente Demo
- Customer: Cadena Sur
- Equipment: LG GR-X24 (EF-REF-002)
- Technician: Operador B
- Status: quote
- Estimated Cost: $900 MXN
- Potential Causes:
- Deterioro en sellos
- Falla en manguera de drenaje
- Estimated Time: 1-2 horas
- Suggested Parts:
- Kit de sellos
- Manguera de drenaje
- Technical Advice: “Confirmar presión y estado de juntas antes del reemplazo.”
InventorySeeder
Creates inventory items for parts and supplies. File:database/seeders/InventorySeeder.php
Items Created:
For ElectroFix Cliente Demo (4 items):
-
Capacitor 25uF
- Code: REF-CAP-25
- Quantity: 18 units
- Low Stock Threshold: 8 units
- Sale Enabled: No
- Sale Price: N/A
-
Tarjeta Control Universal
- Code: REF-TCU-110
- Quantity: 4 units
- Low Stock Threshold: 5 units (BELOW THRESHOLD)
- Sale Enabled: Yes
- Sale Price: $1,450.00 MXN
-
Bomba de Drenaje
- Code: REF-BDR-22
- Quantity: 10 units
- Low Stock Threshold: 4 units
- Sale Enabled: Yes
- Sale Price: $780.00 MXN
-
Kit de Sellos
- Code: REF-KSE-09
- Quantity: 3 units
- Low Stock Threshold: 4 units (BELOW THRESHOLD)
- Sale Enabled: Yes
- Sale Price: $320.00 MXN
For ElectroFix Developer Lab (1 item):
- Módulo de prueba laboratorio
- Code: DEV-LAB-001
- Quantity: 12 units
- Low Stock Threshold: 2 units
- Sale Enabled: No
- Sale Price: N/A
BillingSeeder
Creates sample billing documents with line items. File:database/seeders/BillingSeeder.php
Documents Created:
Billing Document 1: Mixed Quote
Header:- Company: ElectroFix Cliente Demo
- Document Number: DOC-001-000001
- Type: quote
- Created By: Admin ElectroFix
- Customer: Empresa Norte (registered customer)
- Source: mixed (service + product)
- Tax Mode: excluded (tax calculated separately)
- VAT Rate: 16%
- Issued: Current timestamp
-
Service Item
- Kind: service
- Description: “Diagnóstico técnico inicial”
- Quantity: 1
- Unit Price: $600.00
- Subtotal: $600.00
- VAT: $96.00
- Total: $696.00
-
Product Item (from inventory)
- Kind: product
- Description: Capacitor 25uF (from inventory)
- Inventory Item: REF-CAP-25
- Quantity: 1
- Unit Price: $400.00
- Subtotal: $400.00
- VAT: $64.00
- Total: $464.00
- Subtotal: $1,000.00
- VAT (16%): $160.00
- Total: $1,160.00 MXN
Seeder Features
Idempotency
All seeders useupdateOrCreate() instead of create(), making them safe to run multiple times:
Relationships
Seeders maintain referential integrity:- Users belong to companies
- Customers belong to companies
- Equipment belongs to customers and companies
- Orders reference customers, equipment, and companies
- Inventory items belong to companies
- Billing documents reference users, customers, and companies
Multi-Tenancy Testing
Two separate companies allow testing:- Data isolation
- Cross-tenant query protection
- Company-specific features
- Subscription plan differences
Real-World Scenarios
Demo data includes:- Low stock alerts (items below threshold)
- Different order statuses (diagnostic, quote)
- AI diagnostics with JSON data
- Mixed billing (services + products)
- Tax calculations
- Multi-currency support (MXN)
Resetting Demo Data
To reset to fresh demo data:Custom Seeding
To create your own seeder:DatabaseSeeder.php:
Next Steps
- Database Migrations - Understand database schema
- Local Development - Set up development environment
- Configuration Guide - Environment configuration