Overview
Creating an employee in SushiGo involves registering their profile information, assigning roles, and establishing their initial employment period. The system automatically creates a linked user account and sends welcome notifications.Prerequisites
- You must have
manageroradminrole to create employees - Branch must exist where employee will work
- Employee code must be unique (system can suggest next available code)
Employee Code System
Code Structure
Employee codes follow a configurable pattern:Configuration
Located inconfig/employees.php:
Getting Next Available Code
The system provides an endpoint to suggest the next available code:Code Validation Rules
Uniqueness
Code must be unique across all employees, including soft-deleted records
Max Length
Maximum 20 characters
Case Handling
Automatically converted to uppercase
Format
No specific format required beyond uniqueness
Required Fields
Basic Information
| Field | Type | Validation | Example |
|---|---|---|---|
code | string | Required, unique, max 20 chars | EMP-001 |
first_name | string | Required, max 100 chars | Juan |
last_name | string | Required, max 100 chars | Pérez |
roles | array | Required, min 1 role | ["cook"] |
Contact Information
| Field | Type | Validation | Example | Notes |
|---|---|---|---|---|
email | string | Email format, unique, max 255 | [email protected] | Required if phone not provided |
phone | string | 10 digits, unique | 5512345678 | Required if email not provided |
Phone Number Handling
- Input format: 10-digit national number (no country code, no spaces/dashes)
- System processing: Non-digit characters stripped automatically
- Country code: Automatically added (+52 for Mexico) via
config/employees.default_phone_country - Storage: Stored as digits only in
users.phone, country inusers.phone_country
Example: Phone Number Processing
Example: Phone Number Processing
User Input (all valid)
Stored in Database
Employment Information
| Field | Type | Validation | Example | Notes |
|---|---|---|---|---|
branch_id | integer | Required, must exist | 1 | Initial branch assignment |
start_date | string | Required, ISO 8601 date | 2026-01-15 | Employment start date |
Optional Fields
| Field | Type | Validation | Example |
|---|---|---|---|
meta | object | Optional JSON object | {"notes": "..."} |
Role Assignment
Available Roles
- Operational Roles
- Administrative Roles
- manager: Branch manager with oversight responsibilities
- cook: Kitchen staff for food preparation
- kitchen-assistant: Kitchen support staff
- delivery-driver: Order delivery personnel
- acting-manager: Temporary manager designation
Role Assignment Rules
- Minimum requirement: At least one role must be assigned
- Multiple roles: Employees can have multiple roles
- Privilege restriction: Non-super-admins cannot assign
super-adminrole - Format: Roles provided as array of strings
Creating an Employee
API Request
Validation Errors
What Happens Behind the Scenes
When you create an employee, the system performs these operations in a database transaction:Create User Account
System creates a
User record with:- Full name (first_name + last_name)
- Email and/or phone
- Random password (32 characters)
- Phone country code (+52)
Create Employee Profile
System creates an
Employee record with:- Link to created user (
user_id) - Employee code (uppercase)
- First and last name
- Active status (
is_active = true) - Optional metadata
Assign Roles
System assigns roles to the User entity using Spatie Permission:
- Validates roles against assignable list
- Syncs roles to user account
- Preserves any non-position roles
Create Employment Period
System creates initial
EmploymentPeriod record with:- Link to employee
- Branch assignment
- Start date
- Active status (
is_active = true) - End date = NULL (currently employed)
The entire operation is wrapped in a database transaction. If any step fails, all changes are rolled back automatically.
Password Setup Flow
Employee Receives Notification
New employee receives welcome message via email or WhatsApp with password setup link
Common Scenarios
Scenario: Employee with Email Only
Request
Valid - Phone not required when email provided
Scenario: Employee with Phone Only
Request
Valid - Email not required when phone provided. Welcome link sent via WhatsApp.
Scenario: Manager with Multiple Roles
Request
Valid - Multiple roles assigned. Employee has both operational (manager) and administrative (admin) permissions.
Scenario: Future Start Date
Request
Valid - Employee can be registered before start date. They can log in and view their profile, but won’t appear in operational attendance views until start date.
Next Steps
After creating an employee, you’ll typically:- Assign or update roles - Modify role assignments
- Create wage history - Set initial wage
- Create employee schedule - Define working hours
- Start tracking attendance - Daily check-in/check-out
Related Documentation
Roles and Permissions
Learn about role management and permissions
Wage History
Set up employee wages and track changes
Employee Schedules
Define working hours and shifts
API Reference
Complete API documentation for employee creation